Re: [Tutor] decorators, __call__ (able) objects

2009-07-16 Thread Todd Matsumoto
Thanks guys, In the example the __call__ method has *args and **kws as arguments. Is that required? Also when, in what situation would you use callable objects? Cheers, T Original-Nachricht Datum: Wed, 15 Jul 2009 12:02:05 -0700 Von: wesley chun wes...@gmail.com An: vince

Re: [Tutor] decorators, __call__ (able) objects

2009-07-16 Thread Vince Spicer
no the __call__ function can is like any function def __call__(self, passedin): or simply def __call__(self) *args and **kws explained http://www.saltycrane.com/blog/2008/01/how-to- use-args-and-kwargs-in-python/ On Thursday 16 July 2009 12:09:52 am Todd Matsumoto wrote: Thanks guys,

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

[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] 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] = '_')

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 cwi...@compuscan.co.za mailto:cwi...@compuscan.co.za wrote: Chris Castillo wrote: I'm having some trouble reading multiple data types from a single

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 cwi...@compuscan.co.za mailto:cwi...@compuscan.co.za wrote: snip 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

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

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] 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

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 eduardo.su...@gmail.com: 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

Re: [Tutor] Replace a character by index

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

Re: [Tutor] Fwd: The why

2009-07-16 Thread Kent Johnson
From: chris Hynes cjhyne...@hotmail.com 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

Re: [Tutor] Replace a character by index

2009-07-16 Thread Kent Johnson
On Thu, Jul 16, 2009 at 4:29 AM, Waynesri...@gmail.com 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

Re: [Tutor] just one question

2009-07-16 Thread Rich Lovely
2009/7/16 amr...@iisermohali.ac.in: 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

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 amr...@iisermohali.ac.in: 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

Re: [Tutor] Replace a character by index

2009-07-16 Thread Wayne
On Thu, Jul 16, 2009 at 5:50 AM, Kent Johnson ken...@tds.net wrote: On Thu, Jul 16, 2009 at 4:29 AM, Waynesri...@gmail.com 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]:

[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 in

[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: Signal name=abcde

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

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:

Re: [Tutor] interactive naming of pointers

2009-07-16 Thread Wayne
On Thu, Jul 16, 2009 at 9:38 AM, chris Hynes cjhyne...@hotmail.com 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

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 amr...@iisermohali.ac.in: Thankyou for help it is working and giving the result but

Re: [Tutor] objects becoming pointers

2009-07-16 Thread Alan Gauld
chris Hynes cjhyne...@hotmail.com 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

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

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

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' elif y

[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

[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

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 =

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 cjhyne...@hotmail.com mailto:cjhyne...@hotmail.com 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:

Re: [Tutor] help

2009-07-16 Thread Alan Gauld
jonathan wallis mindboggle...@gmail.com 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

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

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 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] 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

[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

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