Wayne Werner, 15.01.2011 03:25:
On Fri, Jan 14, 2011 at 4:42 PM, Terry Carroll wrote:
On Fri, 14 Jan 2011, Karim wrote:
from xml.etree.ElementTree import ElementTree
I don't think straight XML parsing will work on this, as it's not valid
XML; it just looks XML-like enough to cause confusion.
Please always reply to the list, not just to me.
On 1/14/2011 10:42 PM, walter weston wrote:
I want a whole number thats 5 digits long, I want to use it as a
password and if I just type random.random() I get a long float.
random.randint(a, b)
Return a random integer N such that a <= N <= b.
walter weston wrote:
when I print random.random() it always returns a float why is this? how do I
change it to a whole number?
Because random.random() is defined to always return a float between 0
and 1. That's what it does.
If you want a random whole number, you can call random.randint or
On Fri, Jan 14, 2011 at 9:25 PM, bob gailer wrote:
> On 1/14/2011 10:02 PM, walter weston wrote:
>
> when I print random.random() it always returns a float why is this? how do
> I change it to a whole number?
>
>
> That depends on what behavior you want.
>
> If you RTFM you will see:
> random.r
On 01/-10/-28163 02:59 PM, walter weston wrote:
I generate a random number(supposedly a password, in my case its just a long
floating point lol),I want the user to reinput that number and I want to print
a string if the number entered is correct. so if m==num(num is the number
generated and m
On 1/14/2011 10:02 PM, walter weston wrote:
when I print random.random() it always returns a float why is this?
how do I change it to a whole number?
That depends on what behavior you want.
If you RTFM you will see:
random.random()
Return the next random floating point number in the range
Adding reply to list -
On Sat, Jan 15, 2011 at 2:55 AM, walter weston wrote:
> I only want to generate a random number once
>
Then you don't need a for loop. Think of a for loop as something you
need when you want to run a piece of code several times, for example
for x in range(1,6):
print('
> import random
> for x in range(0,1):
> num = random.random()
> print (num)
> m=input('input pass:')
> if m==num:
> print('you entered correctly, proceed')
Your problem lines in the differences in between the types - your num
variable is a float, whereas your m variable i
On 1/14/11, walter weston wrote:
>
> I generate a random number(supposedly a password, in my case its just a long
> floating point lol),I want the user to reinput that number and I want to
> print a string if the number entered is correct. so if m==num(num is the
> number generated and m is the va
On Fri, Jan 14, 2011 at 4:42 PM, Terry Carroll wrote:
>
>
> On Fri, 14 Jan 2011, Karim wrote:
>
> from xml.etree.ElementTree import ElementTree
>>
>
> I don't think straight XML parsing will work on this, as it's not valid
> XML; it just looks XML-like enough to cause confusion.
>
>
It's worth
I generate a random number(supposedly a password, in my case its just a long
floating point lol),I want the user to reinput that number and I want to print
a string if the number entered is correct. so if m==num(num is the number
generated and m is the variable which stores the input ) then I w
On 01/14/2011 08:17 PM, Joel Knoll wrote:
> Hello,
>
> I am new to programming and to Python. I've been using Python with IDLE
> on Windows Vista for a few weeks now.
> (And I'm loving it!) However, I'm thinking about switching to Ubuntu
> 10.10. If I download Ubuntu, will I still be able to u
On Jan 14, 2011, at 8:03 PM, bob gailer wrote:
On 1/14/2011 7:48 PM, Bill DeBroglie wrote:
Hello all,
I don't have a problem per se, but have noticed something that I'd
like to figure out...
Sometimes the "print" function appears orange for me, sometimes it
appears purple. Why does this
Hello,
I am new to programming and to Python. I've been using Python with IDLE on
Windows Vista for a few weeks now.
(And I'm loving it!) However, I'm thinking about switching to Ubuntu 10.10.
If I download Ubuntu, will I still be able to use the
IDLE environment? I am really quite fond
"walter weston" wrote
I have mostly studied python and now I'm ready to
start writing code.
Its usually best to study programming languages *by* writing code.
However since you have now reached that stage of readiness
that's irrelevant advice :-)
I want to print random numbers a certain am
On Fri, Jan 14, 2011 at 8:01 PM, David Hutto wrote:
> Sorry , the tab button doesn't work for text in google mail, and it
> jumped to send
>
>>>
>
> import random
>> for x in range(1,10):
num = random.random()
> print (num)
this should 'bind' your variable to a knew random each t
"Bill DeBroglie" wrote
Sometimes the "print" function appears orange for me, sometimes it
appears purple. Why does this happen and what's the difference
anyway?
THere is probably no difference but one of several things could be
causing it.
First though, the colouring is done by your edit
On 1/14/2011 7:46 PM, walter weston wrote:
I have mostly studied python and now I'm ready to start writing code.
I want to print random numbers a certain ammount of times I am using
the code
import random
print (random.random())
I tried bind the print statement to a variable and when I call
On 1/14/2011 7:48 PM, Bill DeBroglie wrote:
Hello all,
I don't have a problem per se, but have noticed something that I'd
like to figure out...
Sometimes the "print" function appears orange for me, sometimes it
appears purple. Why does this happen and what's the difference anyway?
This seem
Sorry , the tab button doesn't work for text in google mail, and it
jumped to send
>>
import random
> for x in range(1,10):
print (random.random())
This assigns a new random each time, where as outside the for loop it
assigns it once.
___
Tut
Bill DeBroglie wrote:
Hello all,
I don't have a problem per se, but have noticed something that I'd like
to figure out...
Sometimes the "print" function appears orange for me, sometimes it
appears purple. Why does this happen and what's the difference anyway?
Can you explain the context?
On 01/14/2011 07:48 PM, Bill DeBroglie wrote:
> Hello all,
>
> I don't have a problem per se, but have noticed something that I'd
> like to figure out...
>
> Sometimes the "print" function appears orange for me, sometimes it
> appears purple. Why does this happen and what's the difference any
walter weston wrote:
I have mostly studied python and now I'm ready to start writing code. I want to print random numbers a certain ammount of times I am using the code
import random
print (random.random())
I tried bind the print statement to a variable and when I call x for example I
> import random
for x in range(1,10)
> print (random.random())
--
Sometimes...my mama...says I get over excited about technology.
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/li
On 01/14/2011 07:46 PM, walter weston wrote:
> I have mostly studied python and now I'm ready to start writing code. I
> want to print random numbers a certain ammount of times I am using the
> code
>
> import random
> print (random.random())
>
> I tried bind the print statement to a varia
Hello all,
I don't have a problem per se, but have noticed something that I'd
like to figure out...
Sometimes the "print" function appears orange for me, sometimes it
appears purple. Why does this happen and what's the difference anyway?
This seems to be the only function that varies like
I have mostly studied python and now I'm ready to start writing code. I want to
print random numbers a certain ammount of times I am using the code
import random
print (random.random())
I tried bind the print statement to a variable and when I call x for example I
want it to print new
On Fri, 14 Jan 2011, Stefan Behnel wrote:
Terry Carroll, 14.01.2011 03:55:
Does anyone know of a module that can parse out text with XML-like tags as
in the example below? I emphasize the "-like" in "XML-like". I don't think
I can parse this as XML (can I?).
Sample text between the dashed line
* I meant that*: A method actually can be called from the command prompt,
but the syntax is quite different than that used to call a function from the
command prompt.
On Fri, Jan 14, 2011 at 2:37 PM, Ben Ganzfried wrote:
> I actually just figured it out (since the tutorial talks about the
> diffe
I actually just figured it out (since the tutorial talks about the
difference in indentation between a method and a function in a later
chapter). Basically, a method is within a class and therefore cannot be
called from the command prompt whereas a function that stands by itself in a
script can be
Ben Ganzfried wrote:
Hey guys,
I'm using a tutorial geared for a 2.x version of Python and I am currently
using Python 3.1-- so it is possible that my confusion has to do with
different notations between them. But in any case, here is what I have:
My questions are the following:
1) Why is th
On 1/14/11, Ben Ganzfried wrote:
> Hey guys,
>
> I'm using a tutorial geared for a 2.x version of Python and I am currently
> using Python 3.1-- so it is possible that my confusion has to do with
> different notations between them. But in any case, here is what I have:
>
type(Time)
>
t
Hey guys,
I'm using a tutorial geared for a 2.x version of Python and I am currently
using Python 3.1-- so it is possible that my confusion has to do with
different notations between them. But in any case, here is what I have:
>>> type(Time)
>>> t1 = Time()
>>> type(t1)
where:
class Time:
Izz ad-Din Ruhulessin, 14.01.2011 19:49:
Thanks for your quick reply and clearing the issue up for me. Using your
answer, I rewrote the function to this:
double Py_GetAttr_DoubleFromFloat(PyObject *obj, const char *attr)
{
PyObject *get_attr, *py_float;
int has_attr;
//Check if the given
Hi Stefan,
Thanks for your quick reply and clearing the issue up for me. Using your
answer, I rewrote the function to this:
double Py_GetAttr_DoubleFromFloat(PyObject *obj, const char *attr)
>
> {
>
> PyObject *get_attr, *py_float;
>
> int has_attr;
>
>
>> //Check if the given object has the give
On 14-Jan-11 09:03, Jason Staudenmayer wrote:
Don't build you sql separate from the execute (or so I was told when I
was doing something similar)
cur.execute(INSERT INTO tkindbtal (kommune, komnr, i2005, i2006, i2007 \
, i2008, i2009, i2010) VALUES (%s, %s, %s, %s, %s, %s,\
%s, %s)% (cols[0], col
Izz ad-Din Ruhulessin, 14.01.2011 17:52:
I am writing a Python C extension and I have some trouble understanding how
reference counting works exactly. Though I think I understand the practice
on simple operations (see my question at stackoverflow:
http://stackoverflow.com/questions/4657764/py-inc
"Tommy Kaas" wrote
I get a invalid syntax error when I try to run this script - and it's
con.commit() which is highlighted when I get the error.
Aren't you one closing parenthesis short?
cur.execute(sqlinsert,
(cols[0],
Don't build you sql separate from the execute (or so I was told when I was
doing something similar)
cur.execute(INSERT INTO tkindbtal (kommune, komnr, i2005, i2006, i2007 \
, i2008, i2009, i2010) VALUES (%s, %s,%s, %s, %s, %s,\
%s, %s) % (cols[0], cols[1], int(cols[2
Hello,
I am writing a Python C extension and I have some trouble understanding how
reference counting works exactly. Though I think I understand the practice
on simple operations (see my question at stackoverflow:
http://stackoverflow.com/questions/4657764/py-incref-decref-when), but on
more "comp
I get a invalid syntax error when I try to run this script - and it's
con.commit() which is highlighted when I get the error.
I can't see what is wrong. I think it looks like other scripts I'm running
without problems. The scraping part works fine. And the table exists in the
mysql db. I have just
On Fri, Jan 14, 2011 at 1:21 AM, Alan Gauld wrote:
for t in os.walk('Root'):
>
> ... print t
> ...
> And the result is:('Root', ['D1', 'D2', 'D3'], ['FA.txt', 'FB.txt'])
> ('Root/D1', ['D1-1'], ['FC.txt'])
As I only need the first result presented I didn't favor os.walk, yet
tried it any
Terry Carroll, 14.01.2011 03:55:
Does anyone know of a module that can parse out text with XML-like tags as
in the example below? I emphasize the "-like" in "XML-like". I don't think
I can parse this as XML (can I?).
Sample text between the dashed lines::
-
Blah,
Hello,
*from xml.etree.ElementTree import ElementTree
_/#Parsing:/_
doc = ElementTree()
doc.parse(xmlFile)
*
/_*#Find tag element:*_/
*doc.find('mytag')*
*_/#iteration over tag element:/_
lname = []
for lib in doc.iter('LibTag'):
libName = lib.attrib['name']
lname.append(libName)
*
R
I will agree that it seems odd, but here is a sample run from my system. I
promise I am not pulling anyone's leg! :-))
wallenpb@Ubuntu-D810:~$ python
Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
45 matches
Mail list logo