>> C:\somepath> intest.py < in.txt
>>
>> There is no output!
>> In fact, I get an error:
>
> Yes, this is a Windows-specific thing. Unfortunately, Windows's
> treatment
> of shell scripts is slightly inconsistant. However, there are
> workarounds
> by making a '.CMD' file. See:
>
>http://a
> C:\somepath> intest.py < in.txt
>
> There is no output!
> In fact, I get an error:
>
> E:\PROJECTS\Python>intest.py < in.txt
> Traceback (most recent call last):
> File "E:\PROJECTS\Python\intest.py", line 2, in ?
> inp = raw_input()
> EOFError: EOF when reading a line
Hi Alan,
Yes, this
Hi gang, a strange one uncovered by a student of my
tutorial.
If you create the following example program, lets call it
intest.py:
### intest.py #
inp = raw_input()while inp != '': print
inp inp = raw_input()
###
And the following data file
Not
On 8/26/05, Alberto Troiano <[EMAIL PROTECTED]> wrote:
Hi everyoneI need to generate a password..It has to be an 8 digit number and it has tobe randomThe code I've been trying is the following:import randomrandom.randrange(,)
The code works but sometimes it picks a number with 7 dig
On Fri, 26 Aug 2005, Alberto Troiano wrote:
> I need to generate a password..It has to be an 8 digit number and it has
> to be random
>
> import random
> random.randrange(,)
>
> The code works but sometimes it picks a number with 7 digits. Is there any
> way that I can tell him
> I need to generate a password..It has to be an 8 digit number and it
> has to be random
I assume you mean a string representing an 8 digit random number?
If so...
> import random
> random.randrange(,)
>
> The code works but sometimes it picks a number with 7 digits. Is
> there a
> Alan, you missed the last part of the code - he writes the rest of
> the data following the match into the file.
I didn't miss it but I did misread it! :-)
>file.write(contents[pos + len(name):])
I assumed 'name' was here referring to the actual value inserted.
But of course that would hav
Sorry for that you will have to change the %09 to a %08 to get 8 digits. I
got a bit to fixated on the
John Ertl
-Original Message-
From: Ertl, John
Sent: Friday, August 26, 2005 2:23 PM
To: Alberto Troiano; tutor@python.org
Subject:RE: [Tutor] Generate 8 d
Alberto
If you don't mind having leading 0 then you could just do the random like
you did then format it to 9 digits.
You could give this a try
num = random.randrange(,)
num8 = "%09i" % num
John Ertl
-Original Message-
From: Byron [mailto:[EMAIL PROTECTED]
Sent:
Hi Alberto,
Here's how to do it:
---
import random
def generateKey():
nums = "0123456789"
strNumber = ""
count = 0
while (count < 8):
strNumber += nums[random.randrange(len(nums))]
count += 1
pri
>This is the first question in the BeautifulSoup FAQ at
>http://www.crummy.com/software/BeautifulSoup/FAQ.html
>Unfortunately the author of BS considers this a problem with your
Python installation! So it
>seems he doesn't have a good understanding of Python and Unicode.
(OK, I can forgive him
>th
Hi Danny,
> If you have a moment, do you mind doing this on your system?
>
Here you go:
>>> import types
>>> print types.StringTypes
(, )
>>> import sys
>>> print sys.version
2.3.4 (#2, May 29 2004, 03:31:27)
[GCC 3.3.3 (Debian 20040417)]
>>> print type(u'hello' in types.StringTypes
True
>>>sys
> Here you go:
>
> >>> import types
> >>> print types.StringTypes
> (, )
> >>> import sys
> >>> print sys.version
> 2.3.4 (#2, May 29 2004, 03:31:27)
> [GCC 3.3.3 (Debian 20040417)]
> >>> print type(u'hello' in types.StringTypes
> True
> >>>sys.getdefaultencoding()
> 'ascii'
[CCing Leonard Richa
hi there,
i got a problem with Tupel and the find() function. I know in the document
are this Keywords which i am looking for but find() always returns -1.
Thanks for the help.
fedora_user
#!/usr/bin/python
# -*- coding:
Hey ALL
The code Kent sent might work ok but I didn't see it because of what Pierre
said about the left 0's
I think I will go with Pietro's approach. I think is neater and shorter than
the randrange approach
Thanks to all that helped
Best Regards
Alberto
>From: Kent Johnson <[EMAIL PROTECTE
Alberto Troiano wrote:
> Hi Kent
>
> Nope...
> Not workingI'm still getting 7 even 6 digits number
Are you sure? It works for me:
>>> import random
>>> random.randrange(1000,)
42247129
>>> for i in range(1000):
... x = random.randrange(1000,)
... if len(str(x)
On Fri, Aug 26, 2005 at 01:50:04PM +, Alberto Troiano wrote:
> Hi everyone
>
> I need to generate a password..It has to be an 8 digit number and it has to
> be random
>
> The code I've been trying is the following:
>
>
> import random
> random.randrange(,)
>
> The code wor
Hi Kent
Nope...
Not workingI'm still getting 7 even 6 digits number
Any other idea?
Thanks
Alberto
>From: Kent Johnson <[EMAIL PROTECTED]>
>CC: tutor@python.org
>Subject: Re: [Tutor] Generate 8 digit random number
>Date: Fri, 26 Aug 2005 10:00:50 -0400
>
>Alberto Troiano wrote:
> > Hi every
Is "0" a valid digit for your password ?
If the answer is "YES" then, remember that the "0" at the left of a
number are juste removed ! In that case, try writing your password with :
"%08d" % password
Pierre
Alberto Troiano a écrit :
> Hi everyone
>
> I need to generate a password..It has to b
Alberto Troiano wrote:
> Hi everyone
>
> I need to generate a password..It has to be an 8 digit number and it has to
> be random
>
> The code I've been trying is the following:
>
>
> import random
> random.randrange(,)
>
> The code works but sometimes it picks a number with 7
Hi everyone
I need to generate a password..It has to be an 8 digit number and it has to
be random
The code I've been trying is the following:
import random
random.randrange(,)
The code works but sometimes it picks a number with 7 digits. Is there any
way that I can tell him t
Jan Eden wrote:
> Hi,
>
> Jan Eden wrote on 26.08.2005:
>
>
>>Hi,
>>
>>I need to use an instance attribute as the default value for a parameter to a
>>method.
>>
>>This obviously won't work:
>>
>>page.Children()
>>
>>def Children(self, id=self.id, level=2):
>>
>>How can I get the id parameter t
Alan G wrote:
> ARe you sure? The problem using seek and write is that if the data
> you are inserting is bigger than your marker you will overwrite the
> data following the marker.
Alan, you missed the last part of the code - he writes the rest of the data
following the match into the file.
Thi
Jan Eden a écrit :
> Hi,
>
> Jan Eden wrote on 26.08.2005:
>
>
>>Hi,
>>
>>I need to use an instance attribute as the default value for a parameter to a
>>method.
>>
>>This obviously won't work:
>>
>>page.Children()
>>
>>def Children(self, id=self.id, level=2):
>>
>>How can I get the id parame
Hi,
Jan Eden wrote on 26.08.2005:
>Hi,
>
>I need to use an instance attribute as the default value for a parameter to a
>method.
>
>This obviously won't work:
>
>page.Children()
>
>def Children(self, id=self.id, level=2):
>
>How can I get the id parameter to use the attribute page.id? I know I c
Hi,
I need to use an instance attribute as the default value for a parameter to a
method.
This obviously won't work:
page.Children()
def Children(self, id=self.id, level=2):
How can I get the id parameter to use the attribute page.id? I know I could
simply use the method call
page.Children(
>
> basically I took the idea and the code example given and wrote this
> little function, i stuck vars in this html page like #email# and
> just used it like this, " insertdata('#email#','[EMAIL PROTECTED]')
>
> works perfect!
ARe you sure? The problem using seek and write is that if the data
y
Daniel Watkins wrote:
> I've run into a bit of trouble with my spider script. Thus far, it is
> able to retrieve all of the data off the website that is contained
> within standard HTML, downloading jpg, gif and bmp images that are
> related to the files (this restriction only being set by a lack o
grouchy wrote:
> Hi,
>
> I'm having bang-my-head-against-a-wall moments trying to figure all of this
> out.
>
from BeautifulSoup import BeautifulSoup
>>>
file = urllib.urlopen("http://www.google.com/search?q=beautifulsoup";)
file = file.read().decode("utf-8")
soup = BeautifulSoup
29 matches
Mail list logo