Re: Beginner question!

2007-12-21 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : On Dec 21, 9:11 am, SMALLp [EMAIL PROTECTED] wrote: (snip) class insertData: def insert(self, dataTable, data): (snip) I think you need to post the real traceback or the real code since your error message doesn't look like it has anything to do with the

Re: Beginner question!

2007-12-21 Thread Bruno Desthuilliers
SMALLp a écrit : (snip) One more question. How does my code looks like. I couldn't find any open source program written in python You must be jocking ? -- http://mail.python.org/mailman/listinfo/python-list

Re: Beginner question: module organisation

2007-06-05 Thread Mail . To . Nathaniel
Thank you for all your help! I'll study the proposals to chose the one I prefer or to create something new :) Anyway, this is a perfect start-up for me. Nathaniel. -- http://mail.python.org/mailman/listinfo/python-list

Re: Beginner question: module organisation

2007-05-19 Thread Rainer Grimm
[EMAIL PROTECTED] wrote: Hello :) I am new to python and I don't have much expirience in object-oriented technologies neither. The problem is the following: I have to create a simple python template script that will always follow the same algorithm, let's say: - read a mesh - transform

Re: Beginner question: module organisation

2007-05-19 Thread 7stud
On May 14, 7:09 am, [EMAIL PROTECTED] wrote: Hello :) I am new to python and I don't have much expirience in object-oriented technologies neither. The problem is the following: I have to create a simple python template script that will always follow the same algorithm, let's say: - read a

Re: Beginner question: module organisation

2007-05-19 Thread 7stud
On May 19, 10:45 am, 7stud [EMAIL PROTECTED] wrote: refineModule.py: --- def refine(userfunc, mesh): #process mesh func(mesh) The last line should be: userfunc(mesh) -- http://mail.python.org/mailman/listinfo/python-list

Re: Beginner question: module organisation

2007-05-14 Thread Nick Vatamaniuc
On May 14, 9:09 am, [EMAIL PROTECTED] wrote: Hello :) I am new to python and I don't have much expirience in object-oriented technologies neither. The problem is the following: I have to create a simple python template script that will always follow the same algorithm, let's say: - read a

Re: Beginner question on threads

2007-04-30 Thread Gabriel Genellina
En Sun, 29 Apr 2007 22:50:59 -0300, Teresa Hardy [EMAIL PROTECTED] escribió: I have successfully made the threading work on a Window XP machine with quad processors but now I am trying to pass some variables around and am fighting with Lock() If there is the possibility that the same

Re: Beginner question: difference between lists and tuples

2007-03-14 Thread Jim
On Mar 14, 3:46 pm, KDawg44 [EMAIL PROTECTED] wrote: I am trying to learn python. I am working through a tutorial on python.org. I am trying to figure out how lists are different than tuples other than changing values at specific indices. You can change lists but not tuples. That has some

Re: Beginner question: difference between lists and tuples

2007-03-14 Thread Bruno Desthuilliers
KDawg44 a écrit : Hi, I am trying to learn python. I am working through a tutorial on python.org. I am trying to figure out how lists are different than tuples other than changing values at specific indices.

Re: Beginner question on text processing

2006-12-29 Thread skip
Harold To illustrate, assume I have a text file, call it test.txt, with Harold the following information: Harold X11 .32 Harold X22 .45 Harold My goal in the python program is to manipulate this file such Harold that a new file would be created that looks like:

Re: beginner question about range with list and list

2006-11-23 Thread Ben Finney
erik gartz [EMAIL PROTECTED] writes: Doesn't {} allocate new memory for the dictionary each time? It almost appears as if the 2nd dictionary created overwrites the first one. URL:http://effbot.org/pyfaq/how-do-i-create-a-multidimensional-list.htm -- \There are only two ways to

Re: beginner question about range with list and list

2006-11-23 Thread Fredrik Lundh
erik gartz wrote: I'm new to python and I'm having difficulty understanding the following code. Why doesn't the variable a contain [[{}, {'x': 0}, {}], [{}, {'x': 1}, {}]] instead. Doesn't {} allocate new memory for the dictionary each time? each time it's *executed*, yes. [{}]*3 doesn't

Re: Beginner question? Classes, variables, ...

2006-06-28 Thread Diez B. Roggisch
Ángel Gutiérrez Rodríguez wrote: The problem: I have two classes: class X: def __init__(self): pass class Y: def __init__(self): self.a=1 self.b=X() and I would like to make 'a' visible inside 'x'. Is there a way to refer to the Y class from the X? To make

Re: Beginner question? Classes, variables, ...

2006-06-28 Thread Diez B. Roggisch
Dennis Lee Bieber wrote: On Wed, 28 Jun 2006 10:35:10 +0200, Diez B. Roggisch [EMAIL PROTECTED] declaimed the following in comp.lang.python: class X: def __init__(self, my_y): self.my_y self.my_y = my_y *argl* Thanks :) No tea so far... Diez --

Re: Beginner question? Classes, variables, ...

2006-06-28 Thread Ángel Gutiérrez Rodríguez
That wa sneat! Thanks! -- Ángel Gutiérrez Rodríguez - [EMAIL PROTECTED] Instituto de Ciencia de los Materiales de Madrid - CSIC SpLine - European Syncrothorn Radiation Facility - Grenoble - France Postal adress: Departamento de Química Física y Analítica Universidad de Oviedo - c/Julián

Re: Beginner question: use function to read text file

2006-06-26 Thread James Stroud
Luke wrote: I'm pretty stuck at the moment and wondering if anyone can spot the problem. Trying to create a function that will read a text file into a list and return that list. I wrote the following function and saved it as 'fileloader.py' def fileload(fname): infile=open(fname)

Re: Beginner question: use function to read text file

2006-06-26 Thread Gary Herron
Luke wrote: I'm pretty stuck at the moment and wondering if anyone can spot the problem. Trying to create a function that will read a text file into a list and return that list. I wrote the following function and saved it as 'fileloader.py' def fileload(fname): infile=open(fname)

Re: Beginner question: use function to read text file

2006-06-26 Thread Luke
Thanks to both of you for the help, much appreciated! Luke -- http://mail.python.org/mailman/listinfo/python-list

Re: beginner question on dinamin buiding of arg list

2006-03-05 Thread Alex Martelli
Sandro Dentella [EMAIL PROTECTED] wrote: I need to build-up an arg list to pass to a function. Suppose I have a dictionary: opts = { 'user' : 'jack', 'addr' : 'Green Str.'} and I want to build a cmd line like this: select( user='jack', addr='Green Str.' ) select(**opts) should

Re: beginner question fibonacci

2005-07-17 Thread Robert Kern
Joon wrote: # Fibonacci series: ... # the sum of two elements defines the next ... a, b = 0, 1 while b 10: ... print b ... a, b = b, a+b ... 1 1 2 3 5 8 a, b = 0, 1 while b 10: print b a = b b = a+b 1 2 4 8 Why a, b = b,

Re: beginner question fibonacci

2005-07-17 Thread Michael Hoffman
Joon wrote: a, b = 0, 1 while b 10: print b a = b b = a+b 1 2 4 8 Why a, b = b, a+b isn't a = b; b = a+b ? Because you changed a before you added it to b. Let's call your existing a and b a0 and b0, and the next a and b a1 and b1. When you do a, b = b, a+b

Re: beginner question fibonacci

2005-07-17 Thread ralobao
The case is that Python in attribution commands solves first the right side, so he atributes the vars. So the a+b expression is executed first. Joon escreveu: # Fibonacci series: ... # the sum of two elements defines the next ... a, b = 0, 1 while b 10: ... print b ... a, b

Re: beginner question fibonacci

2005-07-17 Thread Joon
Yes, i see. Thank you very much for the fast help! -- http://mail.python.org/mailman/listinfo/python-list

Re: Beginner question: Converting Single-Element tuples to list

2005-06-29 Thread Paul McGuire
Steve - Good catch - in v1.3, I added some Unicode support for pyparsing, although I have not gotten much feedback that anyone is using it, or how well it works. So it is preferable to test against basestring instead of str. -- Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Beginner question: Converting Single-Element tuples to list

2005-06-27 Thread Reinhold Birkenfeld
[EMAIL PROTECTED] wrote: Hi, Thanks for your reply! A new thing learned Allow me to follow that up with another question: Let's say I have a result from a module called pyparsing: Results1 = ['abc', 'def'] Results2 = ['abc'] They are of the ParseResults type: type(Results1)

Re: Beginner question: Converting Single-Element tuples to list

2005-06-27 Thread John Roth
Reinhold Birkenfeld [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi, Thanks for your reply! A new thing learned Allow me to follow that up with another question: Let's say I have a result from a module called pyparsing: Results1 = ['abc', 'def']

Re: Beginner question: Converting Single-Element tuples to list

2005-06-27 Thread Paul McGuire
David - I'm not getting the same results. Run this test program: --- import pyparsing as pp import sys def test(s): results = pp.OneOrMore( pp.Word(pp.alphas) ).parseString( s ) print repr(s),-,list(results) print Python version:, sys.version print pyparsing version:,

Re: Beginner question: Converting Single-Element tuples to list

2005-06-27 Thread Paul McGuire
John - I just modified my test program BNF to use ZeroOrMore instead of OneOrMore, and parsed an empty string. Calling list() on the returned results gives an empty list. What version of pyparsing are you seeing this None/object/list behavior? -- Paul --

Re: Beginner question: Converting Single-Element tuples to list

2005-06-27 Thread Jeff Epler
On Mon, Jun 27, 2005 at 08:21:41AM -0600, John Roth wrote: Unfortunately, I've seen that behavior a number of times: no output is None, one output is the object, more than one is a list of objects. That forces you to have checks for None and list types all over the place. maybe you can at

Re: Beginner question: Converting Single-Element tuples to list

2005-06-27 Thread Paul McGuire
Modified version of test program, to handle empty strings - empty lists. import pyparsing as pp import sys def test(s): results = pp.ZeroOrMore( pp.Word(pp.alphas) ).parseString( s ) print repr(s),-,list(results) print Python version:, sys.version print pyparsing version:,

Re: Beginner question: Converting Single-Element tuples to list

2005-06-27 Thread vdavidster
Hi Paul and everyone else, I ran the script and here's what I got: Python version: 2.4.1 (#2, Mar 31 2005, 00:05:10) [GCC 3.3 20030304 (Apple Computer, Inc. build 1666)] pyparsing version: 1.3 'abc def' - ['abc', 'def'] 'abc' - ['abc'] It seems to work fine. I figured out what my problem was:

Re: Beginner question: Converting Single-Element tuples to list

2005-06-27 Thread Steven Bethard
[EMAIL PROTECTED] wrote: if type(input) == str: You might consider writing this as: if isinstance(input, basestring): I don't know if pyparsing ever produces unicode objects, but in case it does (or it starts to in the future), isinstance is a better call here. STeVe --

Re: Beginner question: Converting Single-Element tuples to list

2005-06-26 Thread Paul McGuire
('abc') is not a tuple - this is an unfortunate result of using ()'s as expression grouping *and* as tuple delimiters. To make ('abc') a tuple, you must add an extra comma, as ('abc',). list( ('abc',) ) ['abc'] -- Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Beginner question: Converting Single-Element tuples to list

2005-06-26 Thread vdavidster
Hi, Thanks for your reply! A new thing learned Allow me to follow that up with another question: Let's say I have a result from a module called pyparsing: Results1 = ['abc', 'def'] Results2 = ['abc'] They are of the ParseResults type: type(Results1) class 'pyparsing.ParseResults'

Re: Beginner question: Logs?

2005-06-03 Thread Peter Hansen
Robert Kern wrote: Greg Ewing wrote: [about the from xxx import * syntax] Better still, don't even *mention* it to a beginner. They don't need to know about it. At all. Really. Well, the OP's use is precisely why from xxx import * exists: the interactive prompt. In that case (and, really,

Re: Beginner question: Logs?

2005-06-02 Thread Peter Hansen
Elliot Temple wrote: from math import * log10(15625) It's always a good idea, especially when answering a beginner's question, to add the caution that this form (from xxx import *) has certain dangers** associated with it, and is widely considered poor style, and should really only rarely be

Re: Beginner question: Logs?

2005-06-02 Thread Terry Reedy
import math math.log10(15625) To find out the names of function in the math module without checking the docs, do dir(math) #same for any other module To get more info, do help(math) # same for any other module with a doc string Terry J. Reedy --

Re: Beginner question: Logs?

2005-06-02 Thread Terry Reedy
Peter Hansen [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Elliot Temple wrote: from math import * log10(15625) It's always a good idea, especially when answering a beginner's question, to add the caution that this form (from xxx import *) has certain dangers** associated with

Re: Beginner question: Logs?

2005-06-02 Thread Greg Ewing
Peter Hansen wrote: It's always a good idea, especially when answering a beginner's question, to add the caution that this form (from xxx import *) has certain dangers** associated with it, and is widely considered poor style, and should really only rarely be used. Better still, don't

Re: Beginner question: Logs?

2005-06-02 Thread Robert Kern
Greg Ewing wrote: Peter Hansen wrote: It's always a good idea, especially when answering a beginner's question, to add the caution that this form (from xxx import *) has certain dangers** associated with it, and is widely considered poor style, and should really only rarely be used.

Re: Beginner question: Logs?

2005-06-01 Thread Robert Kern
Svens wrote: Hey everyone! I'm a math student working on a short script involving logs. I have a function on my scientific calculator, and was wondering if there was a similar funtion in python. For example: (log65536)/(log4)= 8 I've searched around a bit and haven't been able to find

Re: Beginner question: Logs?

2005-06-01 Thread Svens
Hey thanks... Still getting an error message though. Here's what i'm doing: -- import math log10(15625) -- -It says that log10 is not defined, but it is since the module is imported, right? -- http://mail.python.org/mailman/listinfo/python-list

Re: Beginner question: Logs?

2005-06-01 Thread Robert Kern
Svens wrote: Hey thanks... Still getting an error message though. Here's what i'm doing: -- import math log10(15625) -- -It says that log10 is not defined, but it is since the module is imported, right? No, read the tutorial. import math math.log10(15625) -- Robert Kern

Re: Beginner question: Logs?

2005-06-01 Thread Stephen Prinster
Svens wrote: Hey thanks... Still getting an error message though. Here's what i'm doing: -- import math log10(15625) -- -It says that log10 is not defined, but it is since the module is imported, right? try this: import math math.log10(15625) --

Re: Beginner question: Logs?

2005-06-01 Thread Elliot Temple
On Jun 1, 2005, at 9:04 PM, Svens wrote: Hey thanks... Still getting an error message though. Here's what i'm doing: -- import math log10(15625) -- -It says that log10 is not defined, but it is since the module is imported, right? do either import math math.log10(15625)

Re: Beginner question: Python types

2005-05-31 Thread Paul McNett
Uppal, Deepali wrote: Hello, Hello, and welcome to the world of Python. Don't take anything we say too personally, it is meant to help. I am facing a bit of a problem due to python implicitly attaching a type to an object. Ooh. In general, don't say 'implicit'. For the most part, Python

Re: Beginner Question - Very Easy I'm Sure...

2005-03-25 Thread Todd_Calhoun
Thanks for the tip. I knew it was something easy like that. Brian van den Broek [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Todd_Calhoun said unto the world upon 2005-03-24 16:13: I'm trying to generate a random number, and then concetate it to a word to create a password.

Re: Beginner Question - Very Easy I'm Sure...

2005-03-24 Thread Jaime Wyant
str() returns a string, it doesn't change rannum which is still a number... try - rannum = str(rannum) jw On Thu, 24 Mar 2005 13:13:25 -0800, Todd_Calhoun [EMAIL PROTECTED] wrote: I'm trying to generate a random number, and then concetate it to a word to create a password. I get the number

Re: Beginner Question - Very Easy I'm Sure...

2005-03-24 Thread Brian van den Broek
Todd_Calhoun said unto the world upon 2005-03-24 16:13: I'm trying to generate a random number, and then concetate it to a word to create a password. I get the number and assign it to a variable: + word = dog import random rannum = random.randrange(100,999)

<    1   2