[Tutor] How use relative path of Linux environment in Python

2006-04-24 Thread Keo Sophon
Hi all, Do you have any idea of how to use relative path of Linux environment in Python. For example, if a program would like to create an oupfile from these assignment: outputfile = ~/Desktop/ + workingfile, while ~ is the short cut to the path of current user. Thanks, Phon

Re: [Tutor] How use relative path of Linux environment in Python

2006-04-24 Thread Danny Yoo
On Mon, 24 Apr 2006, Keo Sophon wrote: Do you have any idea of how to use relative path of Linux environment in Python. For example, if a program would like to create an oupfile from these assignment: outputfile = ~/Desktop/ + workingfile, while ~ is the short cut to the path of current

Re: [Tutor] [Linux] open a file in any home ~ ?

2006-04-24 Thread kakada
learner404 wrote: It works great, thanks very much to the three of you for these light-speed answers ... I love this list ! Wesley, I've just pre-order your new edition Core Python programming on amazon France, it looks great. :) Thanks I love this list too. Da

Re: [Tutor] Invoking Excel Macro

2006-04-24 Thread arun
Hi Mike, It doesn't display any dialog box rather it gives a temporary name to the file. Ex newsheet.xls as newsheet1.xls So i'm not able to save it. Is there an alternative to invoke the macro and save the file from my script itself .(saving it through macro wud be a better option : ) ) Thanx

[Tutor] Object defined by initialization parameters

2006-04-24 Thread Andre Engels
Is it possible to define a class in such a way, that if twice an object is made with the same initialization parameters, the same object is returned in both cases? More specifically, suppose I have the following program: class myObj(object): def __init__(self,a): self._a = a

Re: [Tutor] hash.update( argv[0] )

2006-04-24 Thread George Georgalis
On Sun, Apr 23, 2006 at 10:49:00PM -0700, Danny Yoo wrote: On Sun, 23 Apr 2006, George Georgalis wrote: Hi! I've been struggling to find a way up seed hash.update() with the sha1 (or similar) of the file that is the program running. this is not a security task but rather a means to generate

Re: [Tutor] Looping over lists of objects

2006-04-24 Thread Ed Singleton
On 24/04/06, Etrade Griffiths [EMAIL PROTECTED] wrote: Hi just feeling my way into Python with a small app that reads data from file, creates objects using that data, stores the objects in a list, loops over the list doing comparison tests to filter out various objects. Here is a code

Re: [Tutor] Looping over lists of objects

2006-04-24 Thread Etrade Griffiths
Ed the problem is that my original code did not have the closing brackets for the method calls get_a and get_b whereas the code snippet I posted did. That's probably why your version works and mine failed. Thanks for your help! Alun At 17:19 24/04/2006, Ed Singleton wrote: On 24/04/06,

Re: [Tutor] How use relative path of Linux environment in Python (fwd)

2006-04-24 Thread Danny Yoo
-- Forwarded message -- Date: Mon, 24 Apr 2006 14:28:34 +0700 From: Keo Sophon [EMAIL PROTECTED] To: Danny Yoo [EMAIL PROTECTED] Subject: Re: [Tutor] How use relative path of Linux environment in Python On Monday 24 April 2006 14:24, you wrote: On Mon, 24 Apr 2006, Keo Sophon

Re: [Tutor] Locking a specific variable (fwd)

2006-04-24 Thread Danny Yoo
-- Forwarded message -- Date: Mon, 24 Apr 2006 07:32:04 -0400 From: Tino Dai [EMAIL PROTECTED] To: Danny Yoo [EMAIL PROTECTED] Subject: Re: [Tutor] Locking a specific variable Hey there Danny, I'm not quite sure I get it, but ok. *grin* I'll assume that fileQueue is an

Re: [Tutor] looking to hire a tutor

2006-04-24 Thread Carroll, Barry
Hello, Meenakshi, -Original Message- Date: Fri, 21 Apr 2006 19:44:57 -0700 (PDT) From: [EMAIL PROTECTED] Subject: [Tutor] looking to hire a tutor To: tutor@python.org Message-ID: [EMAIL PROTECTED] Content-Type: text/plain;charset=iso-8859-1 Hi, I apologize if

Re: [Tutor] Looping over lists of objects

2006-04-24 Thread Danny Yoo
On Mon, 24 Apr 2006, Etrade Griffiths wrote: just feeling my way into Python with a small app that reads data from file, creates objects using that data, stores the objects in a list, loops over the list doing comparison tests to filter out various objects. Here is a code snippet:

Re: [Tutor] Object defined by initialization parameters

2006-04-24 Thread Danny Yoo
On Mon, 24 Apr 2006, Andre Engels wrote: Is it possible to define a class in such a way, that if twice an object is made with the same initialization parameters, the same object is returned in both cases? Yes. The idea is to have the constructor really be a function that delegates off

Re: [Tutor] Locking a specific variable (fwd)

2006-04-24 Thread Danny Yoo
# The way I would like to do it, so we have two different instances of the same variable, and only # one function can access it at a time. If a function comes to that variable and finds a lock on it, # it will wait until the lock is released. And the variable happens to be a queue Hi

Re: [Tutor] hash.update( argv[0] )

2006-04-24 Thread Danny Yoo
where outputVersion is a manual set variable in the program (so I have to purge all the imageFile each time I adjust the program. maybe this is going to work, less progressive approach ^^^ Hi George, Just to make sure: by progressive,

Re: [Tutor] Object defined by initialization parameters

2006-04-24 Thread Bob Gailer
Andre Engels wrote: Is it possible to define a class in such a way, that if twice an object is made with the same initialization parameters, the same object is returned in both cases? Use a factory function, and store a dictionary of instances as a class property: class myObj(object):

Re: [Tutor] Object defined by initialization parameters ADDITION

2006-04-24 Thread Bob Gailer
Bob Gailer wrote: Andre Engels wrote: Is it possible to define a class in such a way, that if twice an object is made with the same initialization parameters, the same object is returned in both cases? Use a "factory" function, and store a dictionary of instances as a

[Tutor] Avoiding the use of files to store intermediate results

2006-04-24 Thread Andre Roberge
I wrote a small wxPython based app to test code snippets. (google for python lightning compiler if you want to see the full code). In the basic mode, I redirect the standard input and output and execute the code taken from the editor window so that the result appears in the output window. Here

Re: [Tutor] Locking a specific variable (fwd)

2006-04-24 Thread Kent Johnson
Yup, I'm familiar with those. In all of the examples, I have seen, the critical region happens in one specific area eg a part of a function with a lock and release around it. My question is there a way to lock a specific variable so that even though other functions are attempting to access it,

[Tutor] Importing Modules

2006-04-24 Thread John Connors
G'day, I'm having trouble understanding the difference between, import sys and from sys import * It seems to me they both do the same thing. John _ New year, new job – there's more than 100,00 jobs at SEEK

Re: [Tutor] Importing Modules

2006-04-24 Thread Alan Gauld
I'm having trouble understanding the difference between, import sys This brings the *name* sys into your module. It does not give you access to any of the names inside sys itself (such as exit for example). To access those you need to prefix them with sys, as in sys.exit() from sys import

[Tutor] Dictionaries and aggregation

2006-04-24 Thread Paul Churchill
I am trying to create a dictionary using data produced by a load balancing admin tool and aggregate the results. When I invoke the tool from within the shell (sudo ~/ZLBbalctl --action="" the following output is produced: Load Balancer 1 usage, over the last 30 seconds Port 80,

Re: [Tutor] Tutor FAQ?

2006-04-24 Thread Mike Hansen
On Apr 22, 2006, at 3:15 AM, Fredrik Lundh wrote: Ed wrote: I don't think the FAQ is open to public editing yet. I'm not sure when it will be, but Fredrik might be able to give a timescale. There are a few known conversion issues to deal with (the FAQ uses a lot more looks like markdown

Re: [Tutor] Invoking Excel Macro

2006-04-24 Thread Mike Hansen
I guess I'm confused. You mentioned that it still throws and error while trying to save the workbook. hmmm Do you get this error when trying to close Excel in the macro? Many times, Excel pops up a dialog box when closing it if there's still a workbook open even if it has been saved.

Re: [Tutor] Tutor FAQ?

2006-04-24 Thread Fredrik Lundh
Mike Hansen wrote: I'll post the questions and answers to the list first. If I don't get any corrections or clarifications in a day or so after posting, I'll add it to the tutor suggestion page. excellent! Ed mentioned that you are using restructured text. Should I put the entry in

[Tutor] need to automate connection

2006-04-24 Thread Payal Rathod
Hi, I need to automate connection to a IP like this. The IP (or domain name) is taken from command line or from user (whichever is easier for me to code). It should emulate, telnet 127.0.0.1 25 mail from: test@test.com 250 ok rcpt to: [EMAIL PROTECTED] 250 ok quit Can Python do this for me?

Re: [Tutor] Avoiding the use of files to store intermediate results

2006-04-24 Thread Hugo González Monteverde
Remember duck typing. An object just needs to look like a file in order to be used like one. Guido's time machine has already forseen your problem. Take a look at the StringIO module. It allows you to use a string where you would normally pass a file object. Hope that helps, Hugo ##

Re: [Tutor] Importing Modules

2006-04-24 Thread -Terry-
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Tomorrow (Apr 25, 2006) at 8:53am, John Connors spoke these wise words: - -G'day, - - - -I'm having trouble understanding the difference between, - - - -import sys - -and - -from sys import * - - - -It seems to me they both do the same thing. - - -