> class junk(object):
> ... pass
> ...
sys.getrefcount(junk)
> 5
> I understand why j1 is 1 higher than I expect, based on the docs,
> but why
> does getrefcount(junk) return 5 before any instances of class junk
> are made?
Because Python s holding 4 references to the class object inte
Message: 8Date: Fri, 13 Oct 2006 02:03:49 +0100From: "Asrarahmed Kadri" <
[EMAIL PROTECTED]>Subject: [Tutor] How to write strings with new line character in afileTo: pythontutor Message-ID:<[EMAIL PROTECTED]>Content-Type: text/plain; charset="iso-8859-1"
Folks,I a
"Meher Kolli" <[EMAIL PROTECTED]> wrote in message
> You can't add \n to a string ..up have use something like this
>
> if str == 'q':
> done = 1
> fd.close()
> else:
> fd.write("%s \n" %(str))
What makes you think so?
>>> s = 'l'
>>> s += '\n'
>>> s
'l\n'
>>>
Seem
Here is the complete code:
fd is the file handle.
import sys
def check_dup(fd1): print fd1 fd1.seek(0,0) done = 0 list1 = [] while not done: x = fd1.readline() if x == "": done = 1 else:
list1.append(x) return list1
fname = raw_in
Folks,
I dont like to swamp your mailboxes with my trivial questions. But please tell me why this isnt working??
str = str + '\n'
fd.write(str) # fd is teh file handle
the traceback is as under:
Traceback (most recent call last): File "scrap.py", line 39, in ? fd.write(str + '\n')IOE
Asrarahmed Kadri wrote:
> Here is the complete code:
> fd is the file handle.
>
> import sys
>
> def check_dup(fd1):
> print fd1
> fd1.seek(0,0)
> done = 0
> list1 = []
> while not done:
> x = fd1.readline()
> if x == "":
> done = 1
> else
Asrarahmed Kadri wrote:
> Folks,
>
> I dont like to swamp your mailboxes with my trivial questions.
We don't mind trivial questions, this is a list for beginners. But there
is no need to swamp our mailboxes by asking the same question more than
once, and if you include complete code and compl
Hi,
Here is a code that reports whether the string is a palindrome or not. I have posted it to help people new to programming ( i am also a newbie) to understand the logic and comment on it.
Share and expand your knowledge as well as understanding...
Happy scripting
Regards,
Asrar
Cod
"Asrarahmed Kadri" <[EMAIL PROTECTED]> wrote in message
> Here is a code that reports whether the string is a palindrome or
> not.
I'd suggest a simpler approach is to use the string/list methods in
Python:
string1 = list(raw_input("enter a string\n")) #using a list is easier
string2 = string
def pal(spam): return spam == spam[::-1]
;-)
--
Cheers,
Simon B
[EMAIL PROTECTED]
http://www.brunningonline.net/simon/blog/
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
Asrarahmed Kadri wrote:
>
> Hi,
>
> Here is a code that reports whether the string is a palindrome or not. I
> have posted it to help people new to programming ( i am also a newbie)
> to understand the logic and comment on it.
>
> Share and expand your knowledge as well as understanding...
>
On 10/13/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]
> wrote:Send Tutor mailing list submissions to
tutor@python.orgTo subscribe or unsubscribe via the World Wide Web, visithttp://mail.python.org/mailman/listinfo/tutoror, via email, send a message with subject or body 'help' to
>> What makes you think so?
>>
>> >>> s = 'l'
>> >>> s += '\n'
>> >>> s
>> 'l\n'
>> >>>
>>
>> Seems to work '\n' is just a character like any other.
>
> The issue was to have a newline or return character after every string,
> Here it is just iterpreted as \n alphabet., but not as a return
Asrarahmed Kadri wrote:
> Yes, you are right; the code isnt working for 'abcdba';
> So what should I do to rectify it.
Try walking through the code by hand so you understand why it is
failing. Then maybe you can figure out how to fix it. It's important to
learn to find and fix errors yourself.
> fname = raw_input("Enter the file name to write data to:\t")
>
> fd = open(fname,'a+')
> print fd
> done = 0
Ok, good, that helps a lot: that's exactly what we need to diagnose the
problem. There appears to be something funky that happens with
append-plus mode. This problem has come up befor
>> Yes, you are right; the code isnt working for 'abcdba';
>> So what should I do to rectify it.
>
> Try walking through the code by hand so you understand why it is
> failing. Then maybe you can figure out how to fix it. It's important to
> learn to find and fix errors yourself.
Hi Asrar,
On
Jonathon Sisson escribió:
> Alfonso wrote:
>
>> Sorry for the too obvious question. I'm new to python and have no idea
>> how can I make execute a compiled .pyc with a double click in linux,
>> with gnome. Trying to double click in a .py gives allways the question
>> wether I want to execute
On Friday 13 October 2006 12:33, Alfonso wrote:
Could be wrong but can't you use file associations? I do on my SUSE system.
John
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
Asrarahmed Kadri wrote:
> Here is the complete code:
> fd is the file handle.
>
> import sys
>
> def check_dup(fd1):
> print fd1
> fd1.seek(0,0)
> done = 0
> list1 = []
> while not done:
> x = fd1.readline()
> if x == "":
> done = 1
> else:
Bob Gailer wrote:
> Asrarahmed Kadri wrote:
>
>> Here is the complete code:
>> fd is the file handle.
>>
>> import sys
>>
>> def check_dup(fd1):
>> print fd1
>> fd1.seek(0,0)
>> done = 0
>> list1 = []
>> while not done:
>> x = fd1.readline()
>> if x == "":
First question..This is the code that I have:for filename in zfile.namelist(): outfile = open(filename, 'w') outfile.write(zfile.read(filename)) outfile.close()Is there a way to say :
for filename in zfile.namelist() contains '.txt, .exe': outfile = open(filename, 'w')
> Is there a way to say :
> for filename in zfile.namelist() contains '.txt, .exe':
Hi Chris,
Yes. It sounds like you want to filter zfile.namelist() and restrict the
entries to those with particular extensions. Try a "list comprehension"
to filter for those interesting filenames:
for fil
At 05:45 PM 10/12/2006, Danny Yoo wrote:
>John Grayson's "Python and Tkinter Programming" is an excellent book on
>learning the Tkinter toolkit:
>
> http://www.manning.com/grayson/
Danny, "Python and Tkinter Programming" is still in its first
edition, which came out in 2000. Python has chang
>From the python_dev LiveJournal community ---
Predict the outcome of the following code:
##
from random import *
seed()
[choice(dict((x+1,0) for x in range(1000))) for x in range(693)][0]
##
--
John.
___
Tutor maillist - Tutor@python.org
http://mai
24 matches
Mail list logo