Re: Parse XML using Python

2004-12-09 Thread Anil

Thomas Guettler wrote:
> Am Wed, 08 Dec 2004 23:25:49 -0800 schrieb anilby:
>
> > Hi,
> >
> > I wanted to write a script that will read the below file:
>
> Hi,
>
> Here is an example how to use sax:
>
> http://pyxml.sourceforge.net/topics/howto/node12.html
>
>  Thomas
>
> --
> Thomas Güttler, http://www.thomas-guettler.de/


Could you please tell me how to achieve the below.
I am interested in  getting the output like:

ABC
EFGA   --> child of ABC
ABDG   --> child of AEFGA
MON   --> child of ABC
A1
 FGA   --> child of A1
 BG--> child of FGA

--
http://mail.python.org/mailman/listinfo/python-list


Re: Parse XML using Python

2004-12-09 Thread Anil

William Park wrote:
> [EMAIL PROTECTED] wrote:
> > Hi,
> >
> > I wanted to write a script that will read the below file:
> >
> > 
> > .
> > 
> > 
> > 
> > ..
> > 
> > ..
> >
> > 
> >
> > ..
> > 
> > ..
> > 
> > ..
> > 
> > .
> > .
> > 
> > .
> > 
> > 
> > 
> > ..
> >
> > 
> >
> > ..
> >
> > 
> >
> > 
> >
> > ..
> > and so on
> >
> > The output of the script shud be
> >
> > ABC
> > ..EFGA
> > ABDG
> > ..MON
> >
> > A1
> > ..FGA
> > BG
> >
> > Please help me in writing a Python script for the above task.
>
> Take a look at
> http://home.eol.ca/~parkw/park-january.html
> on "Expat XML" section towards the end.  Translating it to Python is
> left for homework.
>
> In essence,
> indent=..
> start () {
>   local "${@:2}"
>   echo "${indent|*XML_ELEMENT_DEPTH-1}$label"
> }
> xml -s start "`< file.xml`"
> which prints
> ..ABC
> EFGA
> ..ABDG
> MON
> ..A1
> FGA
> ..BG
> with modified input, ie. wrapping XML pieces into single root tree.
>
> --
> William Park <[EMAIL PROTECTED]>
> Open Geometry Consulting, Toronto, Canada
> Linux solution for data processing.
Thanks everyone for the responses. I will try the above solutions.

-- 
http://mail.python.org/mailman/listinfo/python-list


How to pass a method as argument?

2021-09-30 Thread Anil Anvesh
I want to write a python calculator program that has different methods to add, 
subtract, multiply which takes 2 parameters. I need to have an execute method 
when passed with 3 parameters, should call respective method and perform the 
operation. How can I achieve that?



class calc():
def __init__(self,a,b):
self.a=a
self.b=b

def ex(self,fun):
self.fun=fun
if fun=="add":
self.add()

def add(self):
return self.a+self.b
def sub(self):
return self.a-self.b
def mul(self):
return self.a*self.b
def div (self):
return self.a/self.b
def execu(
obj1=calc()
obj1.execu("add",1,,2)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to pass a method as argument?

2021-10-01 Thread Anil Anvesh
On Friday, October 1, 2021 at 6:04:34 AM UTC+5:30, Mats Wichmann wrote:
> On 9/29/21 23:11, Anil Anvesh wrote: 
> > I want to write a python calculator program that has different methods to 
> > add, subtract, multiply which takes 2 parameters. I need to have an execute 
> > method when passed with 3 parameters, should call respective method and 
> > perform the operation. How can I achieve that? 
> >
> let me add - this is probably not the place you are in your Python 
> learning, so don't worry about this, but the operator module is designed 
> for these kind of usages, when you want to pass an operator like + - 
> etc. but of course can't pass the op itself to take actions because it's 
> not a callable - the operator module has callables that can be used.

I solved it with simple if condition and without using init

#calculator class with arithmetic methods

class calc:
 
def execute(self, func, a, b):
self.a = a
self.b = b
if func == "add":
self.add()
elif func == "sub":
self.sub()
elif func == "mul":
self.mul()
elif func == "div":
self.div()
 
def add(self):
print (self.a,"+",self.b,"=",self.a + self.b)
  
 
def sub(self):
  print (self.a,"-",self.b,"=",self.a - self.b)
 
 
def mul(self):
  print (self.a,"*",self.b,"=",self.a* self.b)

 
def div(self):
print (self.a,"/",self.b,"=",self.a / self.b)
   
 
 
cal = calc()
cal.execute("div", 6, 3)
-- 
https://mail.python.org/mailman/listinfo/python-list


Bwidget for tkinter

2005-10-02 Thread anil . pundoor
hi can i use the bwidgets in tkinter? if so from where can i download
the bwidget for tk inter. and i want to know the installation procedure

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Bwidget for tkinter

2005-10-03 Thread anil . pundoor
thanks u man. i am new to tk inter. i tried installing the lib. but
while running the demo script am getting following error.

python sam.py
Traceback (most recent call last):
  File "sam.py", line 1, in ?
import bwidget, Tkinter, sys, os
  File "/usr/local/lib/python2.2/site-packages/bwidget/__init__.py",
line 149, in ?
class _Frame:
  File "/usr/local/lib/python2.2/site-packages/bwidget/__init__.py",
line 152, in _Frame
getframe = makeswidget(getframe, Tkinter.Frame)
  File "/usr/local/lib/python2.2/site-packages/bwidget/__init__.py",
line 74, in makeswidget
return _wrap(w, f)
  File "/usr/local/lib/python2.2/site-packages/bwidget/__init__.py",
line 59, in _wrap
oldfunc.func_name, wrapper.func_defaults, wrapper.func_closure)
TypeError: function() takes at most 4 arguments (5 given)


can u plz help me

-- 
http://mail.python.org/mailman/listinfo/python-list


bwidget problem

2005-10-03 Thread anil . pundoor
hi
i tried installing the bwidget lib . but
while running the demo script am getting following error.

python sam.py
Traceback (most recent call last):
  File "sam.py", line 1, in ?
import bwidget, Tkinter, sys, os
  File "/usr/local/lib/python2.2/site-packages/bwidget/__init__.py",
line 149, in ?
class _Frame:
  File "/usr/local/lib/python2.2/site-packages/bwidget/__init__.py",
line 152, in _Frame
getframe = makeswidget(getframe, Tkinter.Frame)
  File "/usr/local/lib/python2.2/site-packages/bwidget/__init__.py",
line 74, in makeswidget
return _wrap(w, f)
  File "/usr/local/lib/python2.2/site-packages/bwidget/__init__.py",
line 59, in _wrap
oldfunc.func_name, wrapper.func_defaults, wrapper.func_closure)
TypeError: function() takes at most 4 arguments (5 given)

can u plz help me

-- 
http://mail.python.org/mailman/listinfo/python-list


Multicolumn in Tix scrolledListBox

2006-02-28 Thread anil . pundoor
hi
 iam using Tix ScrolledListBox widget. is there any option so that i
can disply the items in multiple colums
thanks 
Anil

-- 
http://mail.python.org/mailman/listinfo/python-list


Multicolumn in Tix scrolledListBox

2006-02-28 Thread anil . pundoor
hi
 iam using Tix ScrolledListBox widget. is there any option so that i
can disply the items in multiple colums
thanks 
Anil

-- 
http://mail.python.org/mailman/listinfo/python-list


Deleting items from Tix Tree

2006-02-28 Thread anil . pundoor
hi
 iam using Tix tree widget in my python script. how can i delete the
entire tree. i tried the following

self.msgTree = Tix.Tree(self.msgWin)
self.msgTree.hlist.delete()

but it thorws the following error

self.msgTree.hlist.delete()
  File "/usr/local/lib/python2.2/lib-tk/Tix.py", line 320, in
__getattr__
raise AttributeError, name
AttributeError: delete


can some one help me

thanks 
Anil

-- 
http://mail.python.org/mailman/listinfo/python-list


Tix Note Book

2006-03-05 Thread anil . pundoor
hi

am using Tix notebook and i have two frames in that. am adding some
widgets in to both of the frames. now i want to delete all of the
widgets in one of the frame. i dont want to delete the frame, but its
childres.
so how can i get the sub widgets within that frame.

Thanks in advance
Anil

-- 
http://mail.python.org/mailman/listinfo/python-list


python global variable error

2007-03-16 Thread ANIL KARADAĞ

hi, i made a program in python but received global name  error. the program
code;
 serverhost = '127.0.0.1'
   serverport = 2000
   BUFSIZ = 1024
   addr = (serverhost,serverport)
   if str(sys.argv).find("-s") == -1:
   cs = socket(AF_INET, SOCK_STREAM,0) # create a TCP socket
   cs.connect(addr)
   key=1
   main()
   else:
   serversock = socket(AF_INET, SOCK_STREAM)# create a TCP socket
   serversock.bind(addr)
   serversock.listen(2)
   key=2
   print 'waiting for connection…'
   while 1:
   clientsock, addr = serversock.accept()
   print '…connected from:', addr,clientsock
   main()
   serversock.close()

what is difference cs and clientsock? i use cs in main() function or others,
but  don't use clientsock not call from main() "  data = clientsock.recv(BUFSIZ)
NameError: global name 'clientsock' is not defined "

i am sorry, i  little know english
-- 
http://mail.python.org/mailman/listinfo/python-list

File extension

2007-03-16 Thread Anil Kumar

Hi,

Can Python Script can have different extensions like .sh etc Or Is .py
is mandatory to be present as the extension for the Python Script.

We have an application where the script was initially written in shell
script with extension .sh. Now we are migrating this script to be run in
both Unix and Windows, so using Python for migration.

I have created a new Python Script porting all the changes in shell script
and it is working fine in Unix/Linux operating system. Later I changed the
extension of the file from .py to .sh, even then it worked.

But when I try a python script with extension .sh in windows, the file is
not getting recognized by the Python interpreter. Is this supported? Or is
there any way we can achieve the same?

The reason I am trying to change the extension is, it reduces lot of porting
changes. No need to go to each of our file which were referencing .sh file
before and change it to .py.

Any Help would be greatly Appreciated.

Thanks & Regards,
Anil
-- 
http://mail.python.org/mailman/listinfo/python-list

Reloading the already imported module

2007-01-11 Thread anil . pundoor
hi all,
  i have following code


if 
from SIPT.xml_param_mapping import
MESSAGE_PARAMETER_MAPPING
else:
from SIPT.msg_param_mapping import
MESSAGE_PARAMETER_MAPPING


parameter_list = MESSAGE_PARAMETER_MAPPING [
'ABC' ]
for parms in parameter_list:

parameter_list[parms][4] = 'EXPORT'

parameter_list[parms][5] = 'IMPORT'


   After this the xml_param_mapping gets altered. this process is
repeated over couple of time. But every time i need to get a fresh
xml_param_mapping. So how to relaod the already imported module??



regards
Anil

-- 
http://mail.python.org/mailman/listinfo/python-list


Need help in Python automation

2014-03-21 Thread Anil Kumar A
-
Hi All,

I work for an ISP. Currently we bought few switches and routers. Python is 
available in that switches. So I would like to write some scipts which I can 
run inside switch. 

I tried module 'os, system', but It is not executing the commands in 
operational and configurational mode. Those modes' prompts are '*>' and '*#'. 

Can somebody suggest me, if there is any module which I can use to execute 
commands inside a switch.

I don't want to use 'socket' module as I am not connecting the box and 
executing commands. I am running the script inside switch.

Please give some clue to start my automation.

Thanks!

Anil Kumar A

-
-- 
https://mail.python.org/mailman/listinfo/python-list


Python Schduling

2015-07-21 Thread Madduri Anil kumar
Hello Experts,

I am new to Python Programming.I have to work on Python.
I have a requirement to scheduling the script for every one hour.
could you please let me know which packages will be more helpful for Scheduling.
if you post any samples it would be more helpful.

Thanks & Regards,
Anilkumar.M.
-- 
https://mail.python.org/mailman/listinfo/python-list


Send Msg To Specific Tcp Client from Tcp Server Python

2016-08-10 Thread Anil reddy reddy M
I was written a simple tcp server in python, which is nicely communicating with 
multiple tcp clients. My Tcp Server can accept multiple clients at time, each 
client as a new thread. I want send message to specific tcp client after some 
time.
I can client Address from   connction, addr = socket.accept(), but i am not 
able send msg to client with client  IP.POrT. I would be thankfull for any help 
i get

  
   
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Send Msg To Specific Tcp Client from Tcp Server Python

2016-08-10 Thread Anil reddy reddy M
On Thursday, August 11, 2016 at 11:36:47 AM UTC+5:30, dieter wrote:
> Anil reddy reddy M  writes:
> 
> > I was written a simple tcp server in python, which is nicely communicating 
> > with multiple tcp clients. My Tcp Server can accept multiple clients at 
> > time, each client as a new thread. I want send message to specific tcp 
> > client after some time.
> > I can client Address from   connction, addr = socket.accept(), but i am not 
> > able send msg to client with client  IP.POrT. I would be thankfull for any 
> > help i get
> 
> TCP channels are bidirectional: you can send messages in both
> directions. Thus, writing to the server's socket (for a specific client)
> sends the written data to the client.

Hi,
Thanks for your reply, But how can i find client socketfd when i want send 
message to specific client.I can store connected client ip, port in database. 
how can use that ip, port when i want send.

  Sincerely
   Anil,
-- 
https://mail.python.org/mailman/listinfo/python-list