Re: [Tutor] weather scraping with Beautiful Soup

2009-07-16 Thread Alan Gauld
"Che M" wrote Grabbing Weather Underground Data with BeautifulSoup http://flowingdata.com/2007/07/09/grabbing-weather-underground-data-with-beautifulsoup/ But I get to the exact same problem that this other person got to in this post: http://groups.google.com/group/beautifulsoup/browse_threa

Re: [Tutor] pyparsing complex search

2009-07-16 Thread Paul McGuire
> Hi Paul. Thanks. I would like to get better at pyparsing. Can you > recommend a good resource for learning. I am finding that what info I > have found on the subject (on the web) isn't really explaining it from > the ground up as much as I would like. Hrmmm, not sure what to recommend - I might

[Tutor] weather scraping with Beautiful Soup

2009-07-16 Thread Che M
Hi, I am interested in gathering simple weather data using Beautiful Soup, but am having trouble understanding what I'm doing. I have searched the archives and so far haven't found enough to get me moving forward. Basically I am trying to start off this example: Grabbing Weather Underground

Re: [Tutor] objects becoming pointers

2009-07-16 Thread Dave Angel
chris Hynes wrote: That's just it, you won't know in advance what names the user will type in. Maybe I mean to say dynamically create pointers. For instance, In the morning, I might be working with data regarding methanol and do several iterations and save those iterations in separate arrays wi

Re: [Tutor] pyparsing complex search

2009-07-16 Thread pedro
Hi Paul. Thanks. I would like to get better at pyparsing. Can you recommend a good resource for learning. I am finding that what info I have found on the subject (on the web) isn't really explaining it from the ground up as much as I would like. Cheers Pete ___

Re: [Tutor] unittests, testing a type

2009-07-16 Thread Dave Angel
Todd Matsumoto wrote: Hi, Thanks for all the comments so far. DaveA, I'm receiving the value via pyODBC, after running a query on a database. The test is to first make sure the value is a Decimal (pyODBC returns a Decimal object if what is coming from the database is a decimal type). So if I

Re: [Tutor] pyparsing complex search

2009-07-16 Thread Paul McGuire
Pedro - If you are trying to extract a simple pattern like a numeric word followed by an alpha word, I would suggest using one of the scanString or searchString methods. scanString is probably the better choice, since you seem to need not only the matching tokens, but also the location within the

Re: [Tutor] help

2009-07-16 Thread Alan Gauld
"jonathan wallis" wrote i have a duel loop that looks like this while y > 0 and x > 0: This is not any kind of loop its a while expression. It should have a body and that would then constitute a single while loop not a dual loop ( a duel lop has something to do with repeatedl

Re: [Tutor] interactive naming of pointers

2009-07-16 Thread Lie Ryan
Wayne wrote: > On Thu, Jul 16, 2009 at 9:38 AM, chris Hynes > wrote: > > Yeah, I'm not sure if I'm explaining myself well or maybe I'm just > trying to make the code too interactive. > > in my code I would type something like: > > x=zeros((3,3)) >

Re: [Tutor] reading complex data types from text file

2009-07-16 Thread bob gailer
Chris Castillo wrote: *so far I have this and the format is what i want:* -- # Set all necessary variables name = None fileOut = open('outputFile.txt', 'w') total = 0 averageScore = 0 numofScores = 0 score =

[Tutor] Reconstructing phrases from tagged text

2009-07-16 Thread Eduardo Vieira
Hello, I'm scratching my head into solving a problem of transforming a POS-Tagged text in a normal text. My biggest problem is that I can't get the quotes to be placed properly. I had tried a different approach but was advised in the nltk list to use this example, but it does not solve the quoting

[Tutor] pyparsing complex search

2009-07-16 Thread pedro
Hi, well mabe it's not so complex (just for me). I have this code which works fine: #start### from pyparsing import * data = """23 different size pry bars hammer the pitchfork pound felt paper staple the felt paper every to inches staple ham

Re: [Tutor] help

2009-07-16 Thread Lie Ryan
jonathan wallis wrote: > i have a duel loop that looks like thiswhile y > 0 and x > 0: > i cant figure out if there is a way to make so if one loop ends it says > something different than if the other loop ends. > while x > 0 or y > 0: ... if x > 0: print 'x is greater than 0'

Re: [Tutor] objects becoming pointers

2009-07-16 Thread chris Hynes
That's just it, you won't know in advance what names the user will type in. Maybe I mean to say dynamically create pointers. For instance, In the morning, I might be working with data regarding methanol and do several iterations and save those iterations in separate arrays with some type of me

Re: [Tutor] reading complex data types from text file

2009-07-16 Thread Chris Castillo
*so far I have this and the format is what i want:* -- # Set all necessary variables name = None fileOut = open('outputFile.txt', 'w') total = 0 averageScore = 0 numofScores = 0 score = 0 # Header for output f

Re: [Tutor] objects becoming pointers

2009-07-16 Thread Alan Gauld
"chris Hynes" wrote I want the user to input a name, say "Chris". I know I can use the code: name=raw_input() I now want: "Chris"=zeros((3,3)) so that when I type: print Chris This is a common misapprehension by beginners. But let me ask you something. Since you will be writing your

Re: [Tutor] just one question

2009-07-16 Thread amrita
Thankyou very much sir now it is working..it is giving that result which i wanted. Thankyou very much.. Thanks, Amrita > Please use reply-all, so that emails go to the list as well. > > 2009/7/16 : >> Thankyou for help it is working and giving the result but the only >> problem >

Re: [Tutor] interactive naming of pointers

2009-07-16 Thread Wayne
On Thu, Jul 16, 2009 at 9:38 AM, chris Hynes wrote: > Yeah, I'm not sure if I'm explaining myself well or maybe I'm just trying > to make the code too interactive. > > in my code I would type something like: > > x=zeros((3,3)) > > so the pointer called "x" is created by the programmer, but withi

Re: [Tutor] reading complex data types from text file

2009-07-16 Thread Glen Zangirolami
All lines that come back from a text file come back as strings. You can use string methods to detect the data like so: f = open('test.txt') lines = f.readlines() numbers = [] strings = [] for line in lines: if line.strip().isdigit(): numbers.append(int(line)) else: strings.

Re: [Tutor] XML: changing value of elements and writing to a file

2009-07-16 Thread Stefan Behnel
Johan Geldenhuys wrote: > Thanks Stefan (decided to continue with a new thread name), ... which isn't quite enough. As long as you reply to the mail, e-mail/news readers will still sort it into the original thread, so many people will not see it. > I basically wants to create a loop that creates

[Tutor] XML: changing value of elements and writing to a file

2009-07-16 Thread Johan Geldenhuys
Thanks Stefan (decided to continue with a new thread name), I basically wants to create a loop that creates a tree, appends it to the previous tree and write it all to one file...If that makes sense. At the moment my tree is something like this: """ WhatEver """ Now I want to read a di

[Tutor] interactive naming of pointers

2009-07-16 Thread chris Hynes
Yeah, I'm not sure if I'm explaining myself well or maybe I'm just trying to make the code too interactive. in my code I would type something like: x=zeros((3,3)) so the pointer called "x" is created by the programmer, but within the code. What if I wanted to prompt my keyboard user to type i

Re: [Tutor] Replace a character by index

2009-07-16 Thread Wayne
On Thu, Jul 16, 2009 at 5:50 AM, Kent Johnson wrote: > On Thu, Jul 16, 2009 at 4:29 AM, Wayne wrote:> I have > two different ways I can put _ in the word: > > word = 'cat' > > > > ''.join(list(word)[1] = '_') > > Not in any Python I ever used... > In [1]: word = 'cat' > > In [2]: > > In [3]: ''.j

Re: [Tutor] just one question

2009-07-16 Thread Rich Lovely
Please use reply-all, so that emails go to the list as well. 2009/7/16 : > Thankyou for help it is working and giving the result but the only problem > is that it is making a very big file as it is searching for each position > of ALA and first writting its C value then CA then CB like that, is i

Re: [Tutor] just one question

2009-07-16 Thread Rich Lovely
2009/7/16 : > Thanks for your help I tried your commands like:--- > > from __future__ import with_statement #only works on version 2.5 and later > from collections import defaultdict > from decimal import Decimal > > atoms = defaultdict(dict) > > with open("file1.txt") as f: >    for line in f: >

Re: [Tutor] Replace a character by index

2009-07-16 Thread Kent Johnson
On Thu, Jul 16, 2009 at 4:29 AM, Wayne wrote: > Hi, > > My question is more about style/timing than anything else. > > In my program I'm taking a word and generating "blanks" in that word. For > example, the word cat could generate: > _at > c_t > ca_ > > I have two different ways I can put _ in the

Re: [Tutor] Fwd: The why

2009-07-16 Thread Kent Johnson
> From: chris Hynes > Date: 2009/7/15 > Subject: The why > To: roadier...@googlemail.com > > > Well, I'm trying to create an interactive program, let's say I'm > running the program, I ask the user to give the array a name, I then > do some computations and store the results in that array. While I

Re: [Tutor] Replace a character by index

2009-07-16 Thread Andre Engels
On Thu, Jul 16, 2009 at 11:22 AM, Gregor Lingl wrote: > That's simply not true in Python. Try it out! > word = "cat" word[1] = "_" > Traceback (most recent call last): >  File "", line 1, in >   word[1] = "_" > TypeError: 'str' object does not support item assignment And the reason for

Re: [Tutor] [nltk-users] Can't transform a list of tokens into a text

2009-07-16 Thread Steven Bird
2009/7/16 Eduardo Vieira : > > Hello, I have a file that was a resulted from a POS-Tagging program, > after some transformations, I wanted to restore to it's normal form. > So, I used sed to remove the POS-Tags and have something like this: Please show us some output from the POS-Tagging program (

Re: [Tutor] reading complex data types from text file

2009-07-16 Thread Christian Witts
Chris Castillo wrote: Oh okay. gotcha. so I have what I want basically. I just need to check to see if each number meets a certain criteria and output something like the following to a text file. Should I be going about this a different way or should I still use lists? bob below average sue

Re: [Tutor] XML: changing value of elements

2009-07-16 Thread Stefan Behnel
Hi, a new question usually merits a new thread. Especially after a longer time, replies to older threads tend to remain unread as people simply don't scroll down far enough to notice them. You were lucky. :) Johan Geldenhuys wrote: > I have another question about writing the xml tree to a file.

Re: [Tutor] Replace a character by index

2009-07-16 Thread Gregor Lingl
Christian Witts schrieb: Wayne wrote: Hi, ... ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor Strings are essentially a list already of

Re: [Tutor] Replace a character by index

2009-07-16 Thread Christian Witts
Wayne wrote: On Thu, Jul 16, 2009 at 4:06 AM, Christian Witts mailto:cwi...@compuscan.co.za>> wrote: Strings are essentially a list already of characters. What would be slowing down your preferred method #1 would be your explicit cast to a list and then re-joining that list

Re: [Tutor] reading complex data types from text file

2009-07-16 Thread Christian Witts
Chris Castillo wrote: why does your 3rd and fourth lines have brackets? On Thu, Jul 16, 2009 at 1:08 AM, Christian Witts mailto:cwi...@compuscan.co.za>> wrote: Chris Castillo wrote: I'm having some trouble reading multiple data types from a single text file. say

Re: [Tutor] Replace a character by index

2009-07-16 Thread Christian Witts
Wayne wrote: Hi, My question is more about style/timing than anything else. In my program I'm taking a word and generating "blanks" in that word. For example, the word cat could generate: _at c_t ca_ I have two different ways I can put _ in the word: word = 'cat' ''.join(list(word)[1] = '_'

[Tutor] Replace a character by index

2009-07-16 Thread Wayne
Hi, My question is more about style/timing than anything else. In my program I'm taking a word and generating "blanks" in that word. For example, the word cat could generate: _at c_t ca_ I have two different ways I can put _ in the word: word = 'cat' ''.join(list(word)[1] = '_') and # I'm not

Re: [Tutor] Fwd: The why

2009-07-16 Thread Luke Paireepinart
You need to read what dictionaries are. Essentially, any time you think "oh I need to keep separate variables for these values, but I won't know what their names are until runtime!" the correct answer is to not try to manipulate them into variables, but to use them as dictionary keys, or organize t