chinni wrote:
> Hi All,
>
>
> I Want to write a python script to change the permissions(chmod) and
> owner(chown) and group(chgrp) of a file on unix,
> script as to read from the /etc/passwd for displaying available users on
> the machine and from /etc/groups it as to display the available grou
Yes is very possible to do this with python.
Checkout the os.system and os.popen functions to run external commands
(chmod, chown).
Reading the list of users and groups should be easy, just open the
file and read line by line and parse, you can do it as simple as
splitting the line on colon chara
Hi All,
I Want to write a python script to change the permissions(chmod) and
owner(chown) and group(chgrp) of a file on unix,
script as to read from the /etc/passwd for displaying available users on the
machine and from /etc/groups it as to display the available groups and user
has to give the mo
Hi,
i am using a macpro version(10.4.11) and python version is "2.3.5"
Message: 10
Date: Wed, 05 Sep 2007 01:00:44 +0530
From: Noufal Ibrahim <[EMAIL PROTECTED]>
Subject: Re: [Tutor] advanced sorting
To: [EMAIL PROTECTED]
Cc: tutor@python.org
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain
Although I should have expected at least a few problems, I have a question
about a glitch in vista using a wx-implemented script.
Here's the example script-
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#!/usr/bin/python
# togglebuttons.py
import wx
class ToggleButtons(wx.Dialog):
def __init__(sel
Ricardo Aráoz wrote:
> So lets take it a notch up.
> Wanted to change the mfunc method but ONLY for an instance, not a class:
>
MyObj = MyClass()
MyObj.mfunc(data)
> pre change behavior
MyObj.mfunc = newfunc
MyObj.mfunc(data)
> Traceback (most recent call last):
> File "", li
max baseman wrote:
> here is the program sorry copying it from interactive:
>
> >>> number=1
> >>> count=1000
> >>> count=0
> >>> while count < 1000:
> ... if (number*2)%2 == 0:
This will always be true, you multiply by two then check if the result
is divisible by two.
Kent
> ...
>> The big downside is that these changes only apply to the current
>> environment. (Which is the point of an *environment* variable after
>> all :-)
>
>I seem to remember there was a way (in the wds console) to set it
> permanent. Wasn't it 'EXPORT' or something?
I think you might be thinking a
Alan Gauld wrote:
> "Dick Moores" <[EMAIL PROTECTED]> wrote
>
>>> except you lose the flexibility of changing PYTHONPATH
>>> dynamically during a session using SET.
>> Could you show me how to use SET? And an example where it would be
>> useful?
>
> Imagine you are in a DOS command session
>
>
Alan Gauld wrote:
> "Jason Doege" <[EMAIL PROTECTED]> wrote
>
>> I'd like to change the behavior of a class' member function
>> dynamically
>> such that, once changed, all objects of the type would see the new
>> behavior.
>
> class MyClass (object) :
>> def mfunc(self, data):
>>
cool thanks thats what i changed it to than just now i changed to do
something else and instead of leaving the program running for 4 or 5
days as i had been i got my answer in less than a second ^_^"
i realized that i was wasting way to much time checking every
possible answer because the nu
chinni wrote:
>
>
> In Advance Sorting by giving the keywords to sort the list.But, iam
> getting the fallowing errors
>
> >>> x = ['srikanth', 'kumar', 'muppandam', 'will', 'be', 'a']
> >>> x.sort(key=len)
> Traceback (most recent call last):
> File "", line 1, in ?
> TypeError: sort() tak
What version of python are you using?
chinni wrote:
>
>
> In Advance Sorting by giving the keywords to sort the list.But, iam
> getting the fallowing errors
>
> >>> x = ['srikanth', 'kumar', 'muppandam', 'will', 'be', 'a']
> >>> x.sort(key=len)
> Traceback (most recent call last):
> File "", l
"Dick Moores" <[EMAIL PROTECTED]> wrote
> Just to make sure I understand, do you mean that the effects of
> using
> SET do not last between rebootings?
Correct, they only work on the current environment.
Very useful if you have two environments such as development and
test. You can just swap en
chinni wrote:
>
>
> In Advance Sorting by giving the keywords to sort the list.But, iam
> getting the fallowing errors
>
> >>> x = ['srikanth', 'kumar', 'muppandam', 'will', 'be', 'a']
> >>> x.sort(key=len)
> Traceback (most recent call last):
> File "", line 1, in ?
> TypeError: sort() tak
In Advance Sorting by giving the keywords to sort the list.But, iam getting
the fallowing errors
>>> x = ['srikanth', 'kumar', 'muppandam', 'will', 'be', 'a']
>>> x.sort(key=len)
Traceback (most recent call last):
File "", line 1, in ?
TypeError: sort() takes no keyword arguments
>>> x.sort(reve
> This could be written
>kwargs.update(zip(argnames, args))
Nice trick! Thanks for the pointer.
> > return type.__call__(cls, kwargs)
>
> You are passing kwargs as a positional argument to __call__(); i.e.
> passing the dict as an ordinary parameter. To use kwargs as
> the
wormwood_3 wrote:
> I came across the topic of internal Python IDs recently, and learned that the
> internal numeric ids of small integers are cached to increase speed. I had
> read that as of 2.5, this applied to integers between -1 and 100. However,
> doing some quick tests, this seems not to
I came across the topic of internal Python IDs recently, and learned that the
internal numeric ids of small integers are cached to increase speed. I had read
that as of 2.5, this applied to integers between -1 and 100. However, doing
some quick tests, this seems not to be accurate:
Python 2.5.1
Orest Kozyar wrote:
> I have the following code:
>
> class meta(type):
>
> def __call__(cls, *args, **kwargs):
> argnames = inspect.getargspec(cls.__init__)[0]
> for i, value in enumerate(args):
> kwargs[argnames[i]] = value
This could be w
John wrote:
> f2=file(infile,'rb')
>
> Dfmt=['3i','13s','7i','2f','2i','2f','2i','i'] #format for binary
> reading first bits
>
> if f2:
> print infile + ' has been opened'
> #for ft in Dfmt:
> # print ft
> a=(struct.unpack(ft,f2.read(struct.calcsize(ft))) for ft in Dfmt)
>
At 02:35 AM 9/4/2007, Alan Gauld wrote:
>"Dick Moores" <[EMAIL PROTECTED]> wrote
>
> >>except you lose the flexibility of changing PYTHONPATH
> >>dynamically during a session using SET.
> >
> > Could you show me how to use SET? And an example where it would be
> > useful?
>
>Imagine you are in a DO
"Diana Hawksworth" <[EMAIL PROTECTED]> wrote
> How do I find a particular name, change the score and then save
> the changes back to the text file again??
iterate over the file checking (and modifying) each line
write the line back out:
Pseudo code
Out = open('foo.txt','w')
for line in file('f
"Dick Moores" <[EMAIL PROTECTED]> wrote
>>except you lose the flexibility of changing PYTHONPATH
>>dynamically during a session using SET.
>
> Could you show me how to use SET? And an example where it would be
> useful?
Imagine you are in a DOS command session
C:> SET PYTHONPATH=C:\MYNEWFOLDER;
Dear list,
I have been teaching Python with minimal knowledege myself!! I need to be able
to search a text file that perhaps contains names and scores. How do I find a
particular name, change the score and then save the changes back to the text
file again??
Thanks for any help. Diana
Max,
> just wondering if theirs a way to check if a larger number is even
> or
> odd
I notice this is homework so I won't give a direct answer.
But look at the mod operator '%' - It returns the remainder
of an integer division. An even number is exactly divisible
by 2.
HTH,
Alan G.
"max base
"chinni" <[EMAIL PROTECTED]> wrote
>
> i had some doubt about this line can any body clarify this
> plz...
> endings = ['st', 'nd', 'rd'] + 17 * ['th'] + ['st', 'nd', 'rd'] + 7
> * ['th']
> + ['st']
Using the interpreter:
>>> endings = ['st', 'nd', 'rd'] + 17 * ['th'] + ['st', 'nd', 'rd']
"Jason Doege" <[EMAIL PROTECTED]> wrote
> I'd like to change the behavior of a class' member function
> dynamically
> such that, once changed, all objects of the type would see the new
> behavior.
class MyClass (object) :
> def mfunc(self, data):
>print 'pre change behavior'
>
At 12:39 AM 9/3/2007, Alan Gauld wrote:
>"Dick Moores" <[EMAIL PROTECTED]> wrote
>
> > Under Kent's tutelage, I've been experimenting with having no
> > PYTHONDOC,
>
>I assume you mean PYTHONPATH?
Yes. Careless of me.
> > and instead putting a .pth file in
> > E:\Python25\lib\site-packages\ I nam
"John" <[EMAIL PROTECTED]> wrote
>a=(struct.unpack(ft,f2.read(struct.calcsize(ft))) for ft in Dfmt)
>for ln in a: print ln
>
> Which gives me:
>
> /cygdrive/c/washakie/binfile has been opened
> (21, 20060612, 0)
> ('Version 4.3',)
> (21, 12, -86400, -86400, -900, 12, 24)
>
> however, how c
"Trey Keown" <[EMAIL PROTECTED]> wrote
> know if anyone knows of a good example of a simple wxPython text
> editor
wxPython comes with examples of text editors etc.
It uses the amazing Scinitill widget upon which Pythonwin and Scite
are both based.
But look at the Py package which includes PyC
"Ara Kooser" <[EMAIL PROTECTED]> wrote
> What I have so far is a very simple text adventure with two rooms,
> two
> items, and some exits.
So presumably you have a Room class, an Item class and
maybe an Exit class?
> Two question which relates directly to classes: Do you create all
> your ins
32 matches
Mail list logo