On Wed, 11 Jan 2006, Steve Haley wrote:
> I need to do something very simple but I'm having trouble finding the way to
> do it - at least easily. I have created a tuple and now need to find the
> position of individual members of that tuple. Specifically, the tuple is
> something like: words = (
Liam Clarke said unto the world upon 12/01/06 12:32 AM:
> Hi all,
>
> Let's say I have a script called bob.py in a directory called
> c:\pythonstuff, which is in my PATH env_var, and python is also in my
> PATH, and from a completely different directory I call "python bob.py"
> is there a right wa
bob said unto the world upon 11/01/06 10:47 PM:
> At 08:31 PM 1/11/2006, Steve Haley wrote:
>
>>Hello everyone,
>>
>>I need to do something very simple but I'm having trouble finding
>>the way to do it - at least easily. I have created a tuple and now
>>need to find the position of individual m
Hi all,
Let's say I have a script called bob.py in a directory called
c:\pythonstuff, which is in my PATH env_var, and python is also in my
PATH, and from a completely different directory I call "python bob.py"
is there a right way to determine what directory bob.py resides in?
So far I've found
On Thu, 12 Jan 2006, Burge Kurt wrote:
> Again thank you :( and sorry for asking that much questions in one day
> and I know most of them were nonsense ..
Don't worry about it; please feel free to continue to ask questions on the
list. It wasn't quite clear what experience you had before: I ha
At 08:31 PM 1/11/2006, Steve Haley wrote:
>Hello everyone,
>
>I need to do something very simple but I'm having trouble finding
>the way to do it - at least easily. I have created a tuple and now
>need to find the position of individual members of that
>tuple. Specifically, the tuple is someth
Hello everyone,
I need to do something very simple but I'm having trouble finding the way to do it - at least easily. I have created a tuple and now need to find the position of individual members of that tuple. Specifically, the tuple is something like: words = ("you", "me", "us", "we", "and",
hello list
I asked yesterday how we can "declare" an array in python. Thanks Brian
van den Broek and Frank Schley for your responses.
A[None] * n works for me.
To answer Brian's question, I was writing the standard backtracking
procedure to find the permutations of 1..n taken r at a time.
def
On Thu, 12 Jan 2006, Burge Kurt wrote:
> How can I use calloc in python ? Before computing and processing my data
> I want to know how many bytes are available?
Hi Burge,
There's no concept of manual memory allocation in Python, and we don't
have direct access to calloc/malloc/free.
You're as
Hans Dushanthakumar wrote:
> Oops answered my own question. Dynamic importing is done using the
> __import__ function:
>
> t = ["test1.py", "test2.py"] #Actually this list is filled in by a
> Tkinter Listbox selection.
>
> for f in t:
> testname = f[:-3]
> test = __import__("%s"%(testname
Hans Dushanthakumar wrote:
>Oops answered my own question. Dynamic importing is done using the
>__import__ function:
>
>t = ["test1.py", "test2.py"] #Actually this list is filled in by a
>Tkinter Listbox selection.
>
>for f in t:
>testname = f[:-3]
>test = __import__("%s"%(testname))
>
Hans Dushanthakumar wrote:
>Thanks for your reply Kent.
>
>Is it possible to dynamically import a module?
>
>The foll snippet of code throws an error "ImportError: No module named
>testname"
>
>
>t = ["test1.py", "test2.py"] #Actually this list is filled in by a
>Tkinter Listbox selection.
>
>for
On 12/01/06, Hans Dushanthakumar <[EMAIL PROTECTED]> wrote:
> Any other means of importing dynamically?
There's an __import__ builtin. It's a function that takes a string and
returns the module.
eg:
>>> sys = __import__('sys')
>>> sys.platform
'win32'
[actually, it does a bit more than just tha
Oops answered my own question. Dynamic importing is done using the
__import__ function:
t = ["test1.py", "test2.py"] #Actually this list is filled in by a
Tkinter Listbox selection.
for f in t:
testname = f[:-3]
test = __import__("%s"%(testname))
res = test.run_test()
Cheers
Hans
-
Thanks for your reply Kent.
Is it possible to dynamically import a module?
The foll snippet of code throws an error "ImportError: No module named
testname"
t = ["test1.py", "test2.py"] #Actually this list is filled in by a
Tkinter Listbox selection.
for f in t:
testname = f[:-3]
import
Hi again (:
How can I use calloc in python ? Before computing and processing my data I want to know how many bytes are available?
Thanks in advance and best wishes,
Burge
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinf
Burge Kurt wrote:
> Hi,
>
> What is the usage of div_t in python?
>
> I have some unsigned integer variables and want to use ;
>
> div_t div_T;
> div_t div_N;
> div_t div_B;
I guess this is more C code. It doesn't have any Python equivalent -
Python doesn't declare variables and doesn't hav
Hans Dushanthakumar wrote:
> Yes I agree that it'd be cleaner to import the second script and call
> it.
>
> The reason I'm keen to find a alternate method is that I have a whole
> lot of scripts that were designed to run only as standalone scripts. ie
> each of these scripts is not a "function" t
This list is full of people ready to help, I thank you all for the
time you have taken to reply.
Danny now I see where readline could cause headaches,.
Liam thanks for the examples they work great. The endianess will
always be in Big Endian (Motorola type) for this format.
I see why I should be
Yes I agree that it'd be cleaner to import the second script and call
it.
The reason I'm keen to find a alternate method is that I have a whole
lot of scripts that were designed to run only as standalone scripts. ie
each of these scripts is not a "function" that I could just call from
another scri
At 02:59 PM 1/11/2006, Burge Kurt wrote:
>Hi,
>
>What is the usage of div_t in python?
>
>I have some unsigned integer variables and want to use ;
>
>div_t div_T;
>div_t div_N;
>div_t div_B;
Your question is meaningless to me! Please clarify.
div_t is not a Python constant or built_in.
div_t div
Hans Dushanthakumar wrote:
> Hi,
>Can a script return multiple values to the os?
Is there a reason why you have to call the second test.py using
os.system()? I would write it to be imported and called.
test.py
--
def findR():
return 7, 'Hans'
script1.py
-
import test
res
Hi,
What is the usage of div_t in python?
I have some unsigned integer variables and want to use ;
div_t div_T;
div_t div_N;
div_t div_B;
.
.
..
Best for all,
Burge
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/
Hi,
Can a script return multiple values to the os?
What I have in mind is something like the following:
1) Test.py
---
import sys
r = 7
sys.exit(r)
# What I really want to do is something along the lines of sys.exit(r,
"Hans")
2) Script1.py (This script executes script test.py and pri
Thanks for your responses.
Michael Janssen wrote:
>It's perhaps easier to read the information from the /proc filesystem
>(this is where top gets it itself). "man proc" tells where the info is
>stored (guess: /proc/stat).
>
>
>
stat does look in some ways easier. I will say that I found the
st
>
> You mentioned earlier that you're expecting an integer, an integer, and
> then a sequence of float. Don't count bytes if you can help it: let
> Python's struct.calcsize() do this for you.
>
>http://www.python.org/doc/lib/module-struct.html
>
> Your machine may align bytes differently than
Hi,
top is very interactive so it would not be easy at all to parse.
I can suggest reading /proc/loadavg if you're in Linux.
proc(5) ('man 5 proc') says that /proc/loadavg is
The load average numbers give the number of jobs in
the run queue averaged over 1, 5 and 15 minutes.
They
On Wed, 11 Jan 2006, Burge Kurt wrote:
> I f I want to translate C code to Python and have a function like
>
> void get_args(int argc, char* argv[], Argument* args)
> {
Hi Burge,
Also wanted to note that the Standard Library already contains an
argument-parsing library, so you may want to tak
On 1/11/06, Kent Johnson <[EMAIL PROTECTED]> wrote:
> Burge Kurt wrote:
> >
> > void get_args(int argc, char* argv[], Argument* args)
> >
> > My first question about the pointers here; how can I convert them to
> > Python?
>
> Python doesn't have pointers in the sense of direct references to
> memo
I am implementing a computational cluster and am using a job controller
(for want of a better term) that contacts the worker computers,
determines how busy they currently are, and then assigns more work if
the worker computer is below a certain cpu utilization threshhold.
For the cpu threshhold,
Burge Kurt wrote:
> Sorry for the previous message I did it by mistake..
> the function was like below:
>
> void get_args(int argc, char* argv[], Argument* args)
> {
> //check the amount of the arguments
> if(argc%2 == 0)
>{
>printf("Error, incorrect argument numbers : %d\n",a
Hi Burge,
You can access command line argument via sys.argv:
import sys
print sys.argv
This prints a list of the command line arguments. Since argv is a
list, it means you can check its length to get the argument count:
print len( sys.argv )
There is always at least one argument in this list,
Ben Vinger wrote:
> Found the following (which solved the problem, though
> not on the console) at
> http://www.jorendorff.com/articles/unicode/python.html
>
> import codecs
> # Open a UTF-8 file in read mode
> infile = codecs.open("infile.txt", "r", "utf-8")
> # Read its contents as one l
Found the following (which solved the problem, though
not on the console) at
http://www.jorendorff.com/articles/unicode/python.html
import codecs
# Open a UTF-8 file in read mode
infile = codecs.open("infile.txt", "r", "utf-8")
# Read its contents as one large Unicode string.
text = infi
Sorry for the previous message I did it by mistake..the function was like below:
void get_args(int argc, char* argv[], Argument* args){ //check the amount of the arguments if(argc%2 == 0)
{ printf("Error, incorrect argument numbers : %d\n",argc); print_help(); exit(1);
Hi,
I f I want to translate C code to Python and have a function like
void get_args(int argc, char* argv[], Argument* args)
{
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
Hello all
I want to do the following in an XML file:
XFile = open(XmlFile,'r')
for line in XFile.readlines():
if line.find('') > 0:
print line
However, it does not work due to extra characters that
appear in the XML file. For example if I use the
previous code without the if condition
On 11/01/06, Liam Clarke <[EMAIL PROTECTED]> wrote:
> Hi Srinivas -
>
> For walking a directory, you can use os.walk() or os.path.walk(), but
> I prefer the path module here -
> http://www.jorendorff.com/articles/python/path/.
The Path module is excellent, but it's walk still doesn't take into
acc
On Tue, 10 Jan 2006, bill nieuwendorp wrote:
> I am trying to convert binary file to ascii
>
> here is the format spec
>
> steps = int 4
> value = int 4
> time = float 4 * steps
Hi Bill,
Ok, that structure seems fairly simple so far.
> >>> import struct
> >>> import string
> >>> f = file('b
39 matches
Mail list logo