Re: A stupid newbie question about output...

2009-10-20 Thread J
On Tue, Oct 20, 2009 at 16:25, Aahz a...@pythoncraft.com wrote: In article mailman.1745.1256065337.2807.python-l...@python.org, J  dreadpiratej...@gmail.com wrote: The tuple thing is a new concept to me... at least the vocabulary is, I'll go look that up now and learn info on tuples. It's been

Re: Newbie Question regarding __init__()

2009-08-04 Thread Dave Angel
Dennis Lee Bieber wrote: On Mon, 03 Aug 2009 23:00:13 -0400, Dave Angel da...@ieee.org declaimed the following in gmane.comp.python.general: To throw away the result of an expression in Python is even easier. Just don't use it. func1() and func2() is a valid expression whose result

Re: Newbie Question regarding __init__()

2009-08-04 Thread Simon
On Aug 3, 11:00 pm, Dave Angel da...@ieee.org wrote: Simon wrote: On Aug 2, 5:51 am, Dave Angel da...@ieee.org wrote: snip I don't understand your comparison to Foxpro.  read on. As your code was last posted, you don't need a return value from init_Exec()  Every function that doesn't

Re: Newbie Question regarding __init__()

2009-08-03 Thread Simon
On Aug 2, 5:51 am, Dave Angel da...@ieee.org wrote: Simon wrote: Okay I will fix my code and include self and see what happens.  I know I tried that before and got another error which I suspect was another newbie error. The idea behind the init_Pre is that I can put custom code here to

Re: Newbie Question regarding __init__()

2009-08-03 Thread Dave Angel
Simon wrote: On Aug 2, 5:51 am, Dave Angel da...@ieee.org wrote: snip I don't understand your comparison to Foxpro. read on. As your code was last posted, you don't need a return value from init_Exec() Every function that doesn't have an explicit return will return None. And None is

Re: Newbie Question regarding __init__()

2009-08-02 Thread Dave Angel
Simon wrote: Okay I will fix my code and include self and see what happens. I know I tried that before and got another error which I suspect was another newbie error. The idea behind the init_Pre is that I can put custom code here to customize the __init__ instead of creating a new subclass.

Re: Newbie Question regarding __init__()

2009-08-01 Thread Dave Angel
Nat Williams wrote: As MRAB described, ALL instance methods need to accept 'self' as a first parameter, as that will be passed to them implicitly when they are called. This includes __init__. The name 'self' is just a commonly accepted convention for the name of the instance object passed to

Re: Newbie Question regarding __init__()

2009-08-01 Thread Simon
Okay I will fix my code and include self and see what happens. I know I tried that before and got another error which I suspect was another newbie error. The idea behind the init_Pre is that I can put custom code here to customize the __init__ instead of creating a new subclass. This kind of

Newbie Question regarding __init__()

2009-07-31 Thread Simon
Hi I want to create an instance of dcCursor which inherits from dcObject. When I run the following code it gives the error shown. Can some explain to me what is wrong? I have included the dcObject.py and dcCursor.py below. import dcObject import dcCursor x = dcCursor.dcCursor() Traceback

Re: Newbie Question regarding __init__()

2009-07-31 Thread MRAB
Simon wrote: Hi I want to create an instance of dcCursor which inherits from dcObject. When I run the following code it gives the error shown. Can some explain to me what is wrong? I have included the dcObject.py and dcCursor.py below. import dcObject import dcCursor x = dcCursor.dcCursor()

Re: Newbie Question regarding __init__()

2009-07-31 Thread Simon
Hi So should the dcObject class include the self as well since I have not defined an __init__ method in dcCursor? Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie Question regarding __init__()

2009-07-31 Thread Nat Williams
As MRAB described, ALL instance methods need to accept 'self' as a first parameter, as that will be passed to them implicitly when they are called. This includes __init__. The name 'self' is just a commonly accepted convention for the name of the instance object passed to methods. You don't have

Re: Newbie Question regarding __init__()

2009-07-31 Thread Gabriel Genellina
En Fri, 31 Jul 2009 22:53:47 -0300, Simon dciphercomput...@gmail.com escribió: So should the dcObject class include the self as well since I have not defined an __init__ method in dcCursor? Every method that you define takes self as its first argument. Every method that you want to call on

Re: Newbie Question regarding __init__()

2009-07-31 Thread Gabriel Genellina
En Sat, 01 Aug 2009 00:13:05 -0300, Nat Williams nat.willi...@gmail.com escribió: One other thing. I'm a little confused by the first line of dcObject.__init__: self.init_Pre() and self.init_Exec() I suspect this does not do what you think it does. init_Pre and init_Exec will both be

Newbie question - running a command and looking at output

2009-07-18 Thread Dave
I'm trying to run a command (arch -k) and check if the value returned is 'sun4v' or not. kir...@t2:[~] $ arch -k sun4v In fact, I want to do 3 three things 1) Check if the system is Solaris. 2) If it is Solaris, check if 'arch -k' prints 'sun4v' 3) If both 1 and 2 are true, copy a file.

Re: Newbie question - running a command and looking at output

2009-07-18 Thread Dave
Dave wrote: I'm trying to run a command (arch -k) and check if the value returned is 'sun4v' or not. kir...@t2:[~] $ arch -k sun4v In fact, I want to do 3 three things 1) Check if the system is Solaris. 2) If it is Solaris, check if 'arch -k' prints 'sun4v' 3) If both 1 and 2 are true, copy

Re: Newbie question about method options

2009-06-17 Thread Dave Angel
python-newbie113 wrote: I am new to python and have a question about using methods. Here is the link i am looking at: http://www.pythonware.com/library/tkinter/introduction/x2102-methods.htm If i use, create_arc(bbox, options) = id what is id? and how do i find the parameter list representing

Re: Newbie question about method options

2009-06-17 Thread Scott David Daniels
Dave Angel wrote: python-newbie113 wrote: I am new to python and have a question about using methods. Here is the link i am looking at: http://www.pythonware.com/library/tkinter/introduction/x2102-methods.htm If i use, create_arc(bbox, options) = id what is id? and how do i find the parameter

Newbie question about method options

2009-06-16 Thread python-newbie113
I am new to python and have a question about using methods. Here is the link i am looking at: http://www.pythonware.com/library/tkinter/introduction/x2102-methods.htm If i use, create_arc(bbox, options) = id what is id? and how do i find the parameter list representing options? Thanks for help

Re: Newbie question about method options

2009-06-16 Thread Tim Harig
On 2009-06-17, python-newbie113 warhammer1...@gmail.com wrote: If i use, create_arc(bbox, options) = id what is id? and how do i find the parameter list representing options? I am not familiar with tkinker; but, the expression is just showing a function prototype. The function part should be

A newbie question about some code

2009-05-18 Thread Jim Qiu
Hi everyone. I am reading a python library code and found something i can not understand. Please help! class Envelope(object): def __init__(self,ta_info): self.ta_info = ta_info def writefilelist(self,ta_list,tofile): for filename in ta_list: fromfile =

Re: A newbie question about some code

2009-05-18 Thread Rhodri James
On Mon, 18 May 2009 10:18:52 +0100, Jim Qiu bluefishe...@gmail.com wrote: Please check the blue highlighted part, I don't understand how the object get the property? Colours and highlighting don't come across in Usenet postings. Could you be a bit more specific. Which object, and what

Re: A newbie question about some code

2009-05-18 Thread Chris Rebert
On Mon, May 18, 2009 at 2:18 AM, Jim Qiu bluefishe...@gmail.com wrote: Hi everyone. I am reading a python library code and found something i can not understand. Please help! class Envelope(object):     def __init__(self,ta_info):         self.ta_info = ta_info     def

Re: A newbie question about some code

2009-05-18 Thread Jim Qiu
On Mon, May 18, 2009 at 5:30 PM, Rhodri James rho...@wildebst.demon.co.ukwrote: On Mon, 18 May 2009 10:18:52 +0100, Jim Qiu bluefishe...@gmail.com wrote: Please check the blue highlighted part, I don't understand how the object get the property? Colours and highlighting don't come

Re: A newbie question about some code

2009-05-18 Thread Dave Angel
Jim Qiu wrote: Hi everyone. I am reading a python library code and found something i can not understand. Please help! class Envelope(object): def __init__(self,ta_info): self.ta_info = ta_info def writefilelist(self,ta_list,tofile): for filename in ta_list:

Re: a newbie question

2009-04-12 Thread Peter Otten
zhangle2...@gmail.com wrote: I am just learning Python and get a problem when trying this example: from urllib import urlopen doc=urlopen(http://www.python.org;).read() print(doc) when i run this, i was tould that 'cannot import name urlopen What's wrong with this code? Do i need to

Re: a newbie question

2009-04-12 Thread Eugene Perederey
use urllib2 2009/4/12 zhangle2...@gmail.com: hi, I am just learning Python and get a problem when trying this example: from urllib import urlopen doc=urlopen(http://www.python.org;).read() print(doc) when i run this, i was tould that 'cannot import name urlopen What's wrong with this

a newbie question

2009-04-12 Thread zhangle2002
hi, I am just learning Python and get a problem when trying this example: from urllib import urlopen doc=urlopen(http://www.python.org;).read() print(doc) when i run this, i was tould that 'cannot import name urlopen What's wrong with this code? Do i need to place my code in some specific

Re: a newbie question

2009-04-12 Thread larryzhang
On Apr 12, 11:01 pm, Peter Otten __pete...@web.de wrote: zhangle2...@gmail.com wrote: I am just learning Python and get a problem when trying this example: from urllib import urlopen doc=urlopen(http://www.python.org;).read() print(doc) when i run this, i was tould that 'cannot import

Re: Newbie question: How do I add elements to **kwargs in a function?

2009-03-18 Thread Gabriel Genellina
En Tue, 17 Mar 2009 01:24:18 -0200, Aaron Garrett aaron.lee.garr...@gmail.com escribió: On Mar 16, 9:59 pm, Chris Rebert c...@rebertia.com wrote: On Mon, Mar 16, 2009 at 7:48 PM, Aaron Garrett aaron.lee.garr...@gmail.com wrote: I have spent quite a bit of time trying to find the answer on

Newbie question: How do I add elements to **kwargs in a function?

2009-03-16 Thread Aaron Garrett
I have spent quite a bit of time trying to find the answer on this group, but I've been unsuccessful. Here is what I'd like to be able to do: def A(**kwargs): kwargs['eggs'] = 1 def B(**kwargs): print(kwargs) def C(**kwargs): A(**kwargs) B(**kwargs) I'd like to be able to make

Re: Newbie question: How do I add elements to **kwargs in a function?

2009-03-16 Thread Chris Rebert
On Mon, Mar 16, 2009 at 7:48 PM, Aaron Garrett aaron.lee.garr...@gmail.com wrote: I have spent quite a bit of time trying to find the answer on this group, but I've been unsuccessful. Here is what I'd like to be able to do: def A(**kwargs):    kwargs['eggs'] = 1 def B(**kwargs):    

Re: Newbie question: How do I add elements to **kwargs in a function?

2009-03-16 Thread alex goretoy
I think you may need to do something like this in your code, this is what I will be doing here shortly too class peanutsdict(dict): __slots__ = ['defaultZZz'] def __init__(self,default=None): dict.__init(self) self.default = default def __getitem__(self,key):

Re: Newbie question: How do I add elements to **kwargs in a function?

2009-03-16 Thread Aaron Garrett
On Mar 16, 9:59 pm, Chris Rebert c...@rebertia.com wrote: On Mon, Mar 16, 2009 at 7:48 PM, Aaron Garrett aaron.lee.garr...@gmail.com wrote: I have spent quite a bit of time trying to find the answer on this group, but I've been unsuccessful. Here is what I'd like to be able to do:

Newbie Question: Can't multiply sequence by non-int of type 'str'

2009-01-31 Thread Paulo Repreza
Hi, I'm just learning the very basics of python and I ran into this problem in version 3.0/3000: x = input(x: ) x: 36 y = input(y: ) y: 42 print (x*y) Traceback (most recent call last): File pyshell#3, line 1, in module print (x*y) TypeError: can't multiply sequence by non-int of type

Re: Newbie Question: Can't multiply sequence by non-int of type 'str'

2009-01-31 Thread Robert Kern
On 2009-01-31 18:19, Paulo Repreza wrote: Hi, I'm just learning the very basics of python and I ran into this problem in version 3.0/3000: x = input(x: ) x: 36 y = input(y: ) y: 42 print (x*y) Traceback (most recent call last): File pyshell#3, line 1, in module print (x*y) TypeError: can't

Re: Newbie Question: Can't multiply sequence by non-int of type 'str'

2009-01-31 Thread Paulo Repreza
Hi, Thanks for your reply. It worked. Paulo Repreza On Sat, Jan 31, 2009 at 4:25 PM, Robert Kern robert.k...@gmail.com wrote: On 2009-01-31 18:19, Paulo Repreza wrote: Hi, I'm just learning the very basics of python and I ran into this problem in version 3.0/3000: x = input(x: ) x: 36

Re: newbie question: if var1 == var2:

2008-12-12 Thread J. Cliff Dyer
On Thu, 2008-12-11 at 13:44 -0600, Kirk Strauser wrote: At 2008-12-11T17:24:44Z, rdmur...@bitdance.com writes: ' ab c \r\n'.rstrip('\r\n') ' ab c ' ' ab c \n'.rstrip('\r\n') ' ab c ' ' ab c '.rstrip('\r\n') ' ab c ' I didn't say it couldn't

Re: newbie question: if var1 == var2:

2008-12-12 Thread Kirk Strauser
At 2008-12-12T15:35:11Z, J. Cliff Dyer j...@sdf.lonestar.org writes: Python has a version equally good: def chomp(s): return s.rstrip('\r\n') You'll hardly miss Perl at all. ;) I haven't missed Perl in years! I just wish there was a basestring.stripeol method because I seem to end up

Re: newbie question: if var1 == var2:

2008-12-12 Thread MRAB
Kirk Strauser wrote: At 2008-12-12T15:35:11Z, J. Cliff Dyer j...@sdf.lonestar.org writes: Python has a version equally good: def chomp(s): return s.rstrip('\r\n') You'll hardly miss Perl at all. ;) I haven't missed Perl in years! I just wish there was a basestring.stripeol method

newbie question...

2008-12-12 Thread trfilmographer
Hi! Im new at python and I just want to know if (and how) it is possible to send parameters to a program. what I mean is that when we start python I can call a file that should be run like this: python myfile.py can I send additional parameters along with it? like::: python myfile.py myVar1

Re: newbie question...

2008-12-12 Thread Tim Chase
Im new at python and I just want to know if (and how) it is possible to send parameters to a program. what I mean is that when we start python I can call a file that should be run like this: python myfile.py can I send additional parameters along with it? like::: python myfile.py myVar1 myVar2

Re: newbie question...

2008-12-12 Thread r
yes, but your script will need to know hoe to handle this.the following will open a file who's name was passed to the script if len(sys.argv) 1: try: open_file(fname=sys.argv[1]) except: pass -- http://mail.python.org/mailman/listinfo/python-list

Re: newbie question...

2008-12-12 Thread trfilmographer
On Dec 12, 12:59 pm, r rt8...@gmail.com wrote: yes, but your script will need to know hoe to handle this.the following will open a file who's name was passed to the script if len(sys.argv) 1:     try:         open_file(fname=sys.argv[1])     except:         pass ah, ok. now what if I

Re: newbie question...

2008-12-12 Thread r
i was just giving you an example from my TextEditor.py script. this is how arg works lets say you have a script named MyScript.py --- import sys print sys.argv --- call the script with arguments MyScript.py 99 100 ['C:\\Python25\\MyScript.py', '99', '100'] int(sys.argv[1]) - 99 --

Re: newbie question: if var1 == var2:

2008-12-12 Thread Ethan Furman
Andrew Robert wrote: Two issues regarding script. You have a typo on the file you are trying to open. It is listed with a file extension of .in when it should be .ini . Pardon? The OPs original post used .in both in the python code and the command line. Doesn't look like a typo to me.

Re: newbie question...

2008-12-12 Thread Tim Rowe
2008/12/12 trfilmograp...@gmail.com: ah, ok. now what if I want the variable to be an integer that I send? for instance if I send 99 to the program, it is picking it up as a string instead of an integer value. How do I handle this with python?? As 'r' has said, you can cast it to

Re: newbie question: if var1 == var2:

2008-12-11 Thread Kirk Strauser
At 2008-11-29T04:02:11Z, Mel [EMAIL PROTECTED] writes: You could try for item in fname: item = item.strip() This is one case where I really miss Perl's chomp function. It removes a trailing newline and nothing else, so you don't have to worry about losing leading or trailing spaces if

Re: newbie question: if var1 == var2:

2008-12-11 Thread rdmurray
On Thu, 11 Dec 2008 at 10:24, Kirk Strauser wrote: At 2008-11-29T04:02:11Z, Mel [EMAIL PROTECTED] writes: You could try for item in fname: item = item.strip() This is one case where I really miss Perl's chomp function. It removes a trailing newline and nothing else, so you don't have

Re: newbie question: if var1 == var2:

2008-12-11 Thread Steve Holden
Kirk Strauser wrote: At 2008-11-29T04:02:11Z, Mel mwil...@the-wire.com writes: You could try for item in fname: item = item.strip() This is one case where I really miss Perl's chomp function. It removes a trailing newline and nothing else, so you don't have to worry about losing

Re: newbie question: if var1 == var2:

2008-12-11 Thread Kirk Strauser
At 2008-12-11T17:24:44Z, rdmur...@bitdance.com writes: ' ab c \r\n'.rstrip('\r\n') ' ab c ' ' ab c \n'.rstrip('\r\n') ' ab c ' ' ab c '.rstrip('\r\n') ' ab c ' I didn't say it couldn't be done. I just like the Perl version better. -- Kirk Strauser

Re: newbie question: if var1 == var2:

2008-12-11 Thread Steven D'Aprano
On Thu, 11 Dec 2008 13:44:22 -0600, Kirk Strauser wrote: At 2008-12-11T17:24:44Z, rdmur...@bitdance.com writes: ' ab c \r\n'.rstrip('\r\n') ' ab c ' ' ab c \n'.rstrip('\r\n') ' ab c ' ' ab c '.rstrip('\r\n') ' ab c ' I didn't say it couldn't be

Re: newbie question: if var1 == var2:

2008-12-11 Thread Bruno Desthuilliers
Steve Holden a écrit : Kirk Strauser wrote: At 2008-11-29T04:02:11Z, Mel mwil...@the-wire.com writes: You could try for item in fname: item = item.strip() This is one case where I really miss Perl's chomp function. It removes a trailing newline and nothing else, so you don't have to

Re: newbie question: if var1 == var2:

2008-12-11 Thread Kirk Strauser
At 2008-12-11T19:49:23Z, Steve Holden st...@holdenweb.com writes: ... and it's so hard to write item = item[:-1] It's easy - and broken. Bad things happen if you're using something other than '\n' for EOL. -- Kirk Strauser The Day Companies --

Re: newbie question: if var1 == var2:

2008-12-11 Thread Rhodri James
On Thu, 11 Dec 2008 19:49:23 -, Steve Holden st...@holdenweb.com wrote: Kirk Strauser wrote: At 2008-11-29T04:02:11Z, Mel mwil...@the-wire.com writes: You could try for item in fname: item = item.strip() This is one case where I really miss Perl's chomp function. It removes a

Re: newbie question: if var1 == var2:

2008-12-11 Thread greg
Kirk Strauser wrote: At 2008-12-11T19:49:23Z, Steve Holden st...@holdenweb.com writes: item = item[:-1] It's easy - and broken. Bad things happen if you're using something other than '\n' for EOL. Or if the last line of your file doesn't end with a newline. -- Greg --

Re: newbie question: if var1 == var2:

2008-12-11 Thread John Machin
On Dec 12, 10:31 am, Rhodri James rho...@wildebst.demon.co.uk wrote: On Thu, 11 Dec 2008 19:49:23 -, Steve Holden st...@holdenweb.com   wrote: Kirk Strauser wrote: At 2008-11-29T04:02:11Z, Mel mwil...@the-wire.com writes: You could try for item in fname:     item =

Re: newbie question: if var1 == var2:

2008-12-11 Thread Jason Scheirer
On Dec 11, 3:49 pm, John Machin sjmac...@lexicon.net wrote: On Dec 12, 10:31 am, Rhodri James rho...@wildebst.demon.co.uk wrote: On Thu, 11 Dec 2008 19:49:23 -, Steve Holden st...@holdenweb.com   wrote: Kirk Strauser wrote: At 2008-11-29T04:02:11Z, Mel mwil...@the-wire.com

Re: newbie question: if var1 == var2:

2008-12-11 Thread MRAB
Jason Scheirer wrote: On Dec 11, 3:49 pm, John Machin sjmac...@lexicon.net wrote: On Dec 12, 10:31 am, Rhodri James rho...@wildebst.demon.co.uk wrote: On Thu, 11 Dec 2008 19:49:23 -, Steve Holden st...@holdenweb.com wrote: Kirk Strauser wrote: At 2008-11-29T04:02:11Z, Mel

Re: newbie question: if var1 == var2:

2008-12-11 Thread Rhodri James
On Thu, 11 Dec 2008 23:49:10 -, John Machin sjmac...@lexicon.net wrote: On Dec 12, 10:31 am, Rhodri James rho...@wildebst.demon.co.uk wrote: On Thu, 11 Dec 2008 19:49:23 -, Steve Holden st...@holdenweb.com   wrote: ... and it's so hard to write      item = item[:-1] Tsk.  That

Re: newbie question: if var1 == var2:

2008-12-11 Thread John Machin
On Dec 12, 11:39 am, MRAB goo...@mrabarnett.plus.com wrote: Jason Scheirer wrote: On Dec 11, 3:49 pm, John Machin sjmac...@lexicon.net wrote: On Dec 12, 10:31 am, Rhodri James rho...@wildebst.demon.co.uk wrote: On Thu, 11 Dec 2008 19:49:23 -, Steve Holden st...@holdenweb.com  

Re: newbie question: if var1 == var2:

2008-12-11 Thread MRAB
John Machin wrote: On Dec 12, 11:39 am, MRAB goo...@mrabarnett.plus.com wrote: Jason Scheirer wrote: On Dec 11, 3:49 pm, John Machin sjmac...@lexicon.net wrote: On Dec 12, 10:31 am, Rhodri James rho...@wildebst.demon.co.uk wrote: On Thu, 11 Dec 2008 19:49:23 -, Steve Holden

Re: newbie question: if var1 == var2:

2008-12-11 Thread John Machin
On Dec 12, 1:11 pm, MRAB goo...@mrabarnett.plus.com wrote: John Machin wrote: On Dec 12, 11:39 am, MRAB goo...@mrabarnett.plus.com wrote: Jason Scheirer wrote: On Dec 11, 3:49 pm, John Machin sjmac...@lexicon.net wrote: On Dec 12, 10:31 am, Rhodri James rho...@wildebst.demon.co.uk

Re: Quick Newbie Question

2008-12-05 Thread r0g
Josh wrote: Can Python be used on one Linux machine to drive another Linux machine through SSH? I am currently running Putty on my XP box to run tests on a Linux box. I need to automate these tests and thought it would be fun to do so from a Linux VMWare Image I recently setup. Does this

Re: newbie question

2008-12-02 Thread David C. Ullrich
In article [EMAIL PROTECTED], Nan [EMAIL PROTECTED] wrote: Hello, I just started to use Python. I wrote the following code and expected 'main' would be called. def main(): print hello main But I was wrong. I have to use 'main()' to invoke main. The python interpreter does not

newbie question: parse a variable inside an RE?

2008-12-01 Thread joemacbusiness
Hi All, How do I parse a variable inside an RE? What is the re.search() syntax when your search string is a variable? It's easy to parse hardcoded RE's but not if you use a variable. Here is my code, input and runtime: $ cat test45.py #!/usr/bin/python import re resp = raw_input('Selection:

Re: newbie question: parse a variable inside an RE?

2008-12-01 Thread Vlastimil Brom
2008/12/1 [EMAIL PROTECTED] Hi All, How do I parse a variable inside an RE? What is the re.search() syntax when your search string is a variable? It's easy to parse hardcoded RE's but not if you use a variable. Here is my code, input and runtime: $ cat test45.py #!/usr/bin/python

Re: newbie question: parse a variable inside an RE?

2008-12-01 Thread Diez B. Roggisch
[EMAIL PROTECTED] schrieb: Hi All, How do I parse a variable inside an RE? What is the re.search() syntax when your search string is a variable? It's easy to parse hardcoded RE's but not if you use a variable. Both are exactly equal in difficulty. Here is my code, input and runtime: $ cat

Re: newbie question: parse a variable inside an RE?

2008-12-01 Thread John Machin
On Dec 2, 8:56 am, Diez B. Roggisch [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] schrieb: Hi All, How do I parse a variable inside an RE? What is the re.search() syntax when your search string is a variable? It's easy to parse hardcoded RE's but not if you use a variable. Both are

newbie question: if var1 == var2:

2008-11-29 Thread joemacbusiness
Hi All, I dont understand why the following code never finds tree. I could not find the answer in the Python tutorials. Here is the code, test43.in, and runtime: #!/usr/bin/python fname = open(test43.in) var = 'tree' for item in fname: print item: , item, if item == var: print

Re: newbie question: if var1 == var2:

2008-11-29 Thread filtered
Any reason for posting such an issue to the account list? Pillock! On Sat, Nov 29, 2008 at 4:47 AM, [EMAIL PROTECTED] wrote: Hi All, I dont understand why the following code never finds tree. I could not find the answer in the Python tutorials. Here is the code, test43.in, and runtime:

Re: newbie question: if var1 == var2:

2008-11-29 Thread Mike Howard
item = tree\n != 'tree' [EMAIL PROTECTED] wrote: Hi All, I dont understand why the following code never finds tree. I could not find the answer in the Python tutorials. Here is the code, test43.in, and runtime: #!/usr/bin/python fname = open(test43.in) var = 'tree' for item in fname:

Re: newbie question: if var1 == var2:

2008-11-29 Thread kirby urner
It's the newline after each word that's messing you up. var = tree\n ... or if item.strip() == var: ... etc. Kirby On Fri, Nov 28, 2008 at 7:47 PM, [EMAIL PROTECTED] wrote: Hi All, I dont understand why the following code never finds tree. I could not find the answer in the Python

Re: newbie question: if var1 == var2:

2008-11-29 Thread Scott David Daniels
[EMAIL PROTECTED] wrote: Hi All, I dont understand why the following code never finds tree. I could not find the answer in the Python tutorials. Here is the code, test43.in, and runtime: #!/usr/bin/python fname = open(test43.in) var = 'tree' for item in fname: print item: , item, if

Re: Quick Newbie Question

2008-11-29 Thread Josh
alex23 wrote: On Nov 29, 5:09 pm, Josh [EMAIL PROTECTED] wrote: Can Python be used on one Linux machine to drive another Linux machine through SSH? I am currently running Putty on my XP box to run tests on a Linux box. I need to automate these tests and thought it would be fun to do so from a

Re: newbie question: if var1 == var2:

2008-11-29 Thread Reggie Dugard
On Fri, 2008-11-28 at 19:47 -0800, [EMAIL PROTECTED] wrote: Hi All, I dont understand why the following code never finds tree. The problem is that the lines you are reading from the file have a newline at the end so 'tree' != 'tree\n'. See below for suggested changes. I could not find the

Re: newbie question: if var1 == var2:

2008-11-29 Thread Massimo Di Pierro
because when you loop over open(...) is the same as looping over open (...).readlines() and readlines() reads everything including newlines. Try replace: if item == var: with if item.strip() == var: Massimo On Nov 28, 2008, at 9:47 PM, [EMAIL PROTECTED] wrote: Hi All, I dont

Re: newbie question: if var1 == var2:

2008-11-29 Thread John Machin
On Nov 29, 2:53 pm, [EMAIL PROTECTED] wrote: Hi All, I dont understand why the following code cannot find the variable tree.  It is very simple but I could not find the answer to this on the Python Tutorials.  Here is the code, input and runtime: #!/usr/bin/python fname = open(test43.in)

Re: newbie question: if var1 == var2:

2008-11-29 Thread Andrew Robert
Two issues regarding script. You have a typo on the file you are trying to open. It is listed with a file extension of .in when it should be .ini . The next issue is that you are comparing what was read from the file versus the variable. The item read from file also contains and

newbie question: if var1 == var2:

2008-11-28 Thread joemacbusiness
Hi All, I dont understand why the following code cannot find the variable tree. It is very simple but I could not find the answer to this on the Python Tutorials. Here is the code, input and runtime: #!/usr/bin/python fname = open(test43.in) var = 'tree' for item in fname: print item: ,

Re: newbie question: if var1 == var2:

2008-11-28 Thread Mel
[EMAIL PROTECTED] wrote: Hi All, I dont understand why the following code cannot find the variable tree. It is very simple but I could not find the answer to this on the Python Tutorials. Here is the code, input and runtime: #!/usr/bin/python fname = open(test43.in) var = 'tree'

Re: newbie question: if var1 == var2:

2008-11-28 Thread alex23
On Nov 29, 1:53 pm, [EMAIL PROTECTED] wrote: I dont understand why the following code cannot find the variable tree. fname = open(test43.in) var = 'tree' for item in fname: This will include the EOL character for each line. Try adding the following line here: item = item.strip()  

Quick Newbie Question

2008-11-28 Thread Josh
Can Python be used on one Linux machine to drive another Linux machine through SSH? I am currently running Putty on my XP box to run tests on a Linux box. I need to automate these tests and thought it would be fun to do so from a Linux VMWare Image I recently setup. Does this sound do-able

Re: Quick Newbie Question

2008-11-28 Thread alex23
On Nov 29, 5:09 pm, Josh [EMAIL PROTECTED] wrote: Can Python be used on one Linux machine to drive another Linux machine through SSH? I am currently running Putty on my XP box to run tests on a Linux box. I need to automate these tests and thought it would be fun to   do so from a Linux VMWare

Re: newbie question

2008-11-27 Thread Bruno Desthuilliers
Asun Friere a écrit : On Nov 27, 6:11 am, Nan [EMAIL PROTECTED] wrote: Hello, I just started to use Python. I wrote the following code and expected 'main' would be called. def main(): print hello main Not an answer to your question, but I dislike functions named 'main' because the

Re: newbie question

2008-11-27 Thread Asun Friere
On Nov 27, 9:05 pm, Bruno Desthuilliers bruno. [EMAIL PROTECTED] wrote: The problem is that you often have more to do in the __main__ section of a script than just calling one simple function, and you don't necessarily want to pollute the module's namespace with all this code. As I said, it's

Re: newbie question

2008-11-27 Thread Steven D'Aprano
On Thu, 27 Nov 2008 17:58:55 -0800, Asun Friere wrote: if __name__ == '__main__' : import sys sys.exit(main(sys.argv)) Doesn't this just pollute the namespace with main()? Agreed. I don't see anything wrong with that. You have one function more than you otherwise would have had,

newbie question

2008-11-26 Thread Nan
Hello, I just started to use Python. I wrote the following code and expected 'main' would be called. def main(): print hello main But I was wrong. I have to use 'main()' to invoke main. The python interpreter does not give any warnings for the above code. Is there any way/tool to easily

Re: newbie question

2008-11-26 Thread Albert Hopkins
On Wed, 2008-11-26 at 11:11 -0800, Nan wrote: Hello, I just started to use Python. I wrote the following code and expected 'main' would be called. def main(): print hello main But I was wrong. I have to use 'main()' to invoke main. The python interpreter does not give any

Re: newbie question

2008-11-26 Thread Chris Rebert
On Wed, Nov 26, 2008 at 11:11 AM, Nan [EMAIL PROTECTED] wrote: Hello, I just started to use Python. I wrote the following code and expected 'main' would be called. def main(): print hello main But I was wrong. I have to use 'main()' to invoke main. The python interpreter does not

Re: newbie question

2008-11-26 Thread Asun Friere
On Nov 27, 6:11 am, Nan [EMAIL PROTECTED] wrote: Hello,    I just started to use Python. I wrote the following code and expected 'main' would be called. def main():   print hello main Not an answer to your question, but I dislike functions named 'main' because the situation they occur in

Newbie question

2008-11-06 Thread Joe Hays
I'm a newbie to python. Can anyone tell me why the following little program complains about incorrect dimensions? snip import pylab from pylab import * n = 10; m = 2*n; A = randn(m,n); b = A*rand(n,1) + 2*rand(m,1); /snip The actual error I receive is, snip b = A*rand(n,1) + 2*rand(m,1);

Re: Newbie question

2008-11-06 Thread Robert Kern
Joe Hays wrote: I'm a newbie to python. Can anyone tell me why the following little program complains about incorrect dimensions? snip import pylab from pylab import * n = 10; m = 2*n; A = randn(m,n); b = A*rand(n,1) + 2*rand(m,1); /snip The actual error I receive is,

newbie question: apply()

2008-10-04 Thread TK
HI, I need an example for the usage of the apply()-function. Can you help me? Thanks. o-o Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: newbie question: apply()

2008-10-04 Thread Chris Rebert
On Sat, Oct 4, 2008 at 2:25 AM, TK [EMAIL PROTECTED] wrote: HI, I need an example for the usage of the apply()-function. Can you help me? Don't use the apply() function, it's deprecated and unnecessary thanks to Python's enhanced calling syntax, which is described in depth on

Re: newbie question: apply()

2008-10-04 Thread TK
pos_args = [spam, 1, [3]] kwd_args = {b:7, c:9} result = some_function(*pos_args, **kwd_args) Which is equivalent to: result = some_function(spam, 1, [3], b=7, c=9) Which was equivalent to: result = apply(some_function, pos_args, kwd_args) Thanks a lot. o-o Thomas --

can someone explain why this happens- newbie question

2008-09-30 Thread garywood
Hi can someone tell me why it prints the high score table multiple times? #high scores program scores =[] choice = None while choice != 0: print high Score Table 0 - exit 1 - show Scores 2 - add a score 3 - delete a score 4 - sort scores

Re: can someone explain why this happens- newbie question

2008-09-30 Thread Almar Klein
change: for score in scores: print scores to: for score in scores: print score that should do the trick :) Almar 2008/9/30 garywood [EMAIL PROTECTED] Hi can someone tell me why it prints the high score table multiple times? #high scores program scores =[] choice = None while

Re: Newbie question...

2008-09-30 Thread Ken Seehart
Ken D'Ambrosio wrote: First, apologies for such a newbie question; if there's a better forum (I've poked around, some) feel free to point it out to me. Anyway, a mere 25-odd years after first hearing about OOP, I've finally decided to go to it, by way of Python. But this puzzles me: import

Newbie question...

2008-09-29 Thread Ken D'Ambrosio
First, apologies for such a newbie question; if there's a better forum (I've poked around, some) feel free to point it out to me. Anyway, a mere 25-odd years after first hearing about OOP, I've finally decided to go to it, by way of Python. But this puzzles me: import commands free

<    1   2   3   4   5   6   7   8   9   10   >