On Thu, 17 Nov 2005, Eric Walker wrote:
> I have a program now that works just like I want it. Now I want to
> integerate something to say print usage info when the user puts in the
> wrong number or type of options. Also print usage say if you type
> program name and -h or -H. I currently just
> Hi all, i'm a newbie to python and now learning OOP. How do i display
> methods or properties that is owned by a class or a module? for example: i
> know that module sys has a property/method called path. i want to know
> what other methods it has, how do i find them from python command line?
> I'v got a start but I'm stuck because I don't understand how to call
> a tree's nodes by name.
Every time you see call by name, think dictionary.
class Node:
def __init__(self):
self.children = {}
def addChild(self,child,name):
self.children[name] = child
etc.
Hi all, i'm a newbie to python and now learning OOP. How do i display
methods or properties that is owned by a class or a module? for example: i
know that module sys has a property/method called path. i want to know what
other methods it has, how do i find them from python command line?
thx.
r
Let me try to clarify my problem.
I would like to have a tree data structure with trees whose nodes
could have an arbitrary
number of descendants and that I could iterate over by the names of
nodes
this is the first time I've used objects.
I tried to model my code on a binary tree data struc
Erm, a dictionary of names to references?
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of Vincent Wan
Sent: Friday, 18 November 2005 2:21 p.m.
To: tutor@python.org
Subject: [Tutor] building nonbinary trees
I would like to have a tree data structure w
I would like to have a tree data structure with trees whose nodes
could have an arbitrary
number of descendants and that I could iterate over by the names of
nodes
I'v got a start but I'm stuck because I don't understand how to call
a tree's nodes by name.
Here is the code I have so far:
i
All,
I have a program now that works just like I want it. Now I want to
integerate something to say print usage info when the user puts in the wrong
number or type of options. Also print usage say if you type program name and
-h or -H. I currently just have functions defined and at the bottom ma
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
Johan Geldenhuys schrieb:
> This script was not intended to be used from the command line, but to
> be called from elsewhere. It was only a test piece of code.
> If you use the ping command with the args that you are calling it with,
> there is no nee
On 18/11/05, Fred Lionetti <[EMAIL PROTECTED]> wrote:
> Anyone have any idea as to how I could basically "compile" all my
> artwork into a data file for a python application? Would this require
> compiling them into a *.dll/*.so? It seems like there must be any
> easier way--Also, I need my appli
Orri said:
> Or you could just do the following:
>
> >>> print "\n\nWelcome to the Backwards Message Display."
> >>> print
> >>> message = raw_input("\nPlease Enter a Message.")
> >>> print message[::-1]
Interesting. I forgot about the 'step' option when slicing.
> This is the equivalent of pr
Christian Wyglendowski wrote:
>Liam said:
>
>
>>How about -
>>print "\n\nWelcome to the Backwards Message Display."
>>print
>>message = raw_input("\nPlease Enter a Message.")
>>msgAsList = [ char for char in message]
>>
>>
>
>You could also do:
>
>msgAsList = list(message)
>
>list() takes an
Fred said:
>
[snip]
> I've got another question I think you may have come across before.
> I'm planning on purchasing a license to use some stock icons in an
> application I'm developing. The problem is the license requires this:
>
> "Where an application is to be distributed, the graphical me
>list() takes any iterable and returns a list object.
Hmm, I did not know that the list(str) thing worked that way.That'll reduce
the list comprehensions, but is it intuitive? Would a newbie see that and
think that list("Hi") returns ["Hi"] or ["H","i"] ?
>reversedMessage = ''.join(reversed(list
Liam said:
>
> How about -
> print "\n\nWelcome to the Backwards Message Display."
> print
> message = raw_input("\nPlease Enter a Message.")
> msgAsList = [ char for char in message]
You could also do:
msgAsList = list(message)
list() takes any iterable and returns a list object.
> msgAsList.
Hehe,
Sounds like someone's license was designed for C/C++.
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of Fred Lionetti
Sent: Friday, 18 November 2005 8:29 a.m.
To: tutor@python.org
Subject: [Tutor] compiled images
Hi everyone,
Thanks everyone fo
How about -
print "\n\nWelcome to the Backwards Message Display."
print
message = raw_input("\nPlease Enter a Message.")
msgAsList = [ char for char in message]
msgAsList.reverse()
reversedMessage = ''.join(msgAsList)
I can't test that, but it should work.
But, with regard to -
> print "\n\nWel
Hi everyone,
Thanks everyone for the help with lambda expressions! Your
suggestions and discussions were great!
I've got another question I think you may have come across before.
I'm planning on purchasing a license to use some stock icons in an
application I'm developing. The problem is the l
> I can not figure out what kind of expresion I need to use to find Html
> code.
Take a look at the regular expressions topic in my tutorial which gives
an example of stripping stuff from HTML>
However be aware that using regular expressions on html is never
reliable and a proper parser like B
This script was not intended to be used from the command line, but to
be called from elsewhere. It was only a test piece of code.
If you use the ping command with the args that you are calling it with,
there is no need to kill the process, it will terminate after 10
requests. 8-)
Johan
Ch
Johan Geldenhuys wrote:
> What is this line supposedto do?
>
> cmd.run('www.python.org')
Run the command that was defined at object creation ('ping -c 10') with
the argument 'www.python.org'.
Chris
___
Tutor maillist - Tutor@python.org
http://mail.py
What is this line supposedto do?
cmd.run('www.python.org')
Christopher Arndt wrote:
Alan Gauld schrieb:
Thanks, I may use that as one of the example programs if
you don't mind?
I took the liberty of refactoring Johan's example a bit, to make it more
reusable. See attac
That will be great. In the "@TODO" part you will see that I still need
to take the output from the command and capture that into a file. Can
you help me with that?
Johan
Alan Gauld wrote:
> Thanks, I may use that as one of the example programs if
> you don't mind?
>
> Alan G.
>
>
> - Orig
Blah brain freeze I saw my mistake as I hit send.
It should just be word[-2:]
So
#!/usr/bin/python
import sys
for word in sys.argv[1:]:
print word[-2:]
Works now. Thanks!
On 11/17/05, Will Harris <[EMAIL PROTECTED]> wrote:
Is there an easy way to slice the last set of characters off a
Is there an easy way to slice the last set of characters off a string
when I don't know the length of the string? For example say I have a
list of words like
this
though
weather
I want to get the last 2 characters from each. But so far nothing I
have tried has seeme
Hi,
This is what I would like to do.:
1: Read in an Html file as a list with readlines,
2: Loop through the list,
3: Take out the text or number that is between
the Html,
4: Insert the text or number into a new list,
5: print out the new list with the text.
I have a problem with section 3 !
I ca
These both work (though neither is very graceful).
text = "hello"
message = ""
for i in range(len(text)):
message = message + text[(len(text)-i-1)]
print message
lst = list(text)
newstr = ""
for item in text:
newstr += (lst.pop())
print newstr
On 16/11/05, Chad Everett <[EMAIL
Thanks to everyone for the answers. I'll definitely check Numeric Python.
Cheers
Bernard
On 11/16/05, Danny Yoo <[EMAIL PROTECTED]> wrote:
>
>
> On Wed, 16 Nov 2005, Bernard Lebel wrote:
>
> > Let say I have a list of lists. Each individual lists have a bunch of
> > elements. Now I would like
Hi Chris,
Thanks your response.
I have just found another way.
>>> import math
>>> l = (1,2,3,4,5,1,2,3,4,5,1,2,3,4,5)
>>> n = 4
>>> extended = l + ('default',)*int(n - math.fmod(len(l),n))
>>> [extended[i:i+n] for i in range(0,len(extended),n)]
[(1, 2, 3, 4), (5, 1, 2, 3), (4, 5, 1, 2), (3, 4,
for b you can use this code:
a = [10,3,4.6,2.3,4.8,10.8,4.1] b = ['1-4','4.1-8','8.1-12','12.1-16'] for x in a: for y in b: low,up = y.split('-') if float(low) < x < float(up):
print '%s %s - %s' % (x, low, up) break Ch
Fred said:
> >> Obviously, the lambda is using "value" at the end of the loop (4),
> >>rather than what I want, "value" during the loop (0,1,2,3).
Christian said:
> > Right. I think the issue is that your lambda calls another funtion.
> > However, the function isn't called until the lambda is c
Srinivas Iyyer wrote:
> Dear group,
>
> I have a list of numbers:
>
> a = [10,3,4.6,2.3,4.8,10.8,4.1]
> b = ['1-4','4.1-8','8.1-12','12.1-16']
> c = ((1,4),(4.1,8),(8.1-12),(12.1,16))
>
> Now I want to find if elements of list a are in the
> range of list b and in the range of tuple b.
>
> I
Dear group,
I have a list of numbers:
a = [10,3,4.6,2.3,4.8,10.8,4.1]
b = ['1-4','4.1-8','8.1-12','12.1-16']
c = ((1,4),(4.1,8),(8.1-12),(12.1,16))
Now I want to find if elements of list a are in the
range of list b and in the range of tuple b.
I know (and my limited knowledge on range functi
Adisegna wrote:
> So far this is what I have come up with doing some research.
>
> import urllib
> for line in urllib.urlopen('http://mywebsit.com/folder/folder/test.asp'):
> if '400 Bad Request' in line:
>
> text_file = open("mysite.log", "a")
> text_file.writelines(line)
> text_file.w
| Hi,
|
| I couldn't get idea how to make the next thing
|
n=4 #split into so long parts
l = (1,2,3,4,5,1,2,3,4,5,1,2,3,4,5) #this is the tuple to split
[l[i:i+n] for i in range(0,len(l),n)]
| [(1, 2, 3, 4), (5, 1, 2, 3), (4, 5, 1, 2), (3, 4, 5)]
|
| But I have to make it like thi
> Anyway, Can someone point me in the right direction on getting the Telnet
> working? Or if you have a better way to get what I am trying to do
> accomplished. Is there a Python Telnet module?
I think the urllib module will be easier.
Just open the url and read the output into a list. check the
Looks like you pretty well figured it out.
for the timestamp there is the basic timemodule, the datetime module
or the extra module mxdatetime. Each more sophisticated than the last...
Alan G
- Original Message -
From: "Adisegna" <[EMAIL PROTECTED]>
To:
Sent: Thursday, November 17, 2005
Adisegna wrote:
> Hi,
>
> I just started learning Python and would like to try writing a
> monitoring script.
>
> What I would like to do is use Telnet to send a GET via port 80 to a
> status page in a directory to verify my site is up.
I use httplib for this. You can probably do it with urlli
38 matches
Mail list logo