[Tutor] xml parsing without a root element

2011-08-30 Thread rail shafigulin
hello everyone. i need to parse a an xml-like file. the problem that i'm facing is that this file doesn't have the root element but in all other terms it is the same as xml, i.e does anybody know if there is a module in python that allows to process an xml file without a root element? i t

Re: [Tutor] xml parsing without a root element

2011-08-30 Thread rail shafigulin
On Tue, Aug 30, 2011 at 2:20 PM, Peter Otten <__pete...@web.de> wrote: > rail shafigulin wrote: > > > hello everyone. > > > > i need to parse a an xml-like file. the problem that i'm facing is that > > this file doesn't have the root element but in

[Tutor] inheritance, python and pygame

2011-10-11 Thread rail shafigulin
i'm trying to learn OOP, python and pygame at the same time. so far it has been ok, but i stumbled onto a problem here is the code that causes problems #!/usr/bin/python3.1 import pygame pygame.init() class BaseSprite(pygame.sprite.Sprite): def __init(self, imagefile): super(type(self), se

Re: [Tutor] inheritance, python and pygame

2011-10-11 Thread rail shafigulin
On Tue, Oct 11, 2011 at 10:56 AM, Hugo Arts wrote: > On Tue, Oct 11, 2011 at 4:20 PM, rail shafigulin > wrote: > > i'm trying to learn OOP, python and pygame at the same time. so far it > has > > been ok, but i stumbled onto a problem > > > > here is the co

[Tutor] print method name

2011-12-08 Thread rail shafigulin
i created a class and in some instances when i use it call some of its methods i need to print a method name. the online search did produce some results but none of them seem to work for me. for example one of them said just to use __name__ or func_name but it didn't work for me. i'm using python 3

Re: [Tutor] print method name

2011-12-08 Thread rail shafigulin
On Thu, Dec 8, 2011 at 10:17 AM, Joel Goldstick wrote: > > > On Thu, Dec 8, 2011 at 9:49 AM, rail shafigulin > wrote: > >> i created a class and in some instances when i use it call some of its >> methods i need to print a method name. the online search did produce

Re: [Tutor] print method name

2011-12-08 Thread rail shafigulin
On Thu, Dec 8, 2011 at 10:40 AM, Lie Ryan wrote: > On 12/09/2011 01:49 AM, rail shafigulin wrote: > >> i created a class and in some instances when i use it call some of its >> methods i need to print a method name. the online search did produce >> some results but none

[Tutor] attribute overwrite

2011-12-09 Thread rail shafigulin
i need to overwrite and attribute from the inherited class. i also need to run the constructor of the super class. here is the code import datetime class DateTime(datetime.datetime): def __init__(self, year, month, day, *args): super().__init__(year, month, day, *args) if self.year >= 1

Re: [Tutor] attribute overwrite

2011-12-09 Thread rail shafigulin
On Fri, Dec 9, 2011 at 4:43 PM, rail shafigulin wrote: > i need to overwrite and attribute from the inherited class. i also need to > run the constructor of the super class. here is the code > > import datetime > > class DateTime(datetime.datetime): > def __init__(self, ye

[Tutor] timedelta, difference calculation

2011-12-12 Thread rail shafigulin
i found something interesting during the timedate difference calculation import datetime import time def main(): mydatetime = datetime.datetime.now() time.sleep(1) mydatetime2 = datetime.datetime.now() diff = mydatetime - mydatetime2 print(diff) if __name__ == '__main__': main() if

Re: [Tutor] timedelta, difference calculation

2011-12-15 Thread rail shafigulin
On Mon, Dec 12, 2011 at 4:14 PM, Lie Ryan wrote: > On 12/13/2011 06:46 AM, rail shafigulin wrote: > >> i found something interesting during the timedate difference calculation >> >> import datetime >> import time >> >> def main(): >> mydate

[Tutor] modify values for object derived from datetime.datetime

2011-12-15 Thread rail shafigulin
i writing some code to do device testing at my work. testing is related to date and time, so naturally i decided to create a class that inherits from datetime.datetime. main reason is that i need to add, subtract and compare datetime objects and datetime.datetime allows me to do that. here is the c

Re: [Tutor] modify values for object derived from datetime.datetime

2011-12-16 Thread rail shafigulin
On Fri, Dec 16, 2011 at 5:26 AM, Steven D'Aprano wrote: > rail shafigulin wrote: > >> i writing some code to do device testing at my work. testing is related to >> date and time, so naturally i decided to create a class that inherits from >> datetime.datetime. main

[Tutor] __new__ and __init__

2012-08-01 Thread rail shafigulin
Hello everyone. I'm trying to understand how to use the two methods. I know that __new__ is used to create an object, while __init__ to initialize. But I'm not sure what happens when I create an object. I found the following code in the book (Python 3 Object Oriented Programming by Dusty Phillips

[Tutor] optparse.OptionParser options in alphabetical order in help display

2012-12-18 Thread rail shafigulin
Does anybody know if there is a way to make --help option to display options in alphabetical order? Right now it displays options in the order I added them. I'm using Python 3.1 Any help is appreciated. Thanks. ___ Tutor maillist - Tutor@python.org To

Re: [Tutor] optparse.OptionParser options in alphabetical order in help display

2012-12-18 Thread rail shafigulin
t everyone I've shown has switched and were > glad > they did. It's also on PyPi and github. In fact, the github page is > probably the > best place to check it out. > > -Modulok- > > On 12/18/12, rail shafigulin wrote: > > Does anybody know if there is a way

Re: [Tutor] optparse.OptionParser options in alphabetical order in help display

2012-12-18 Thread rail shafigulin
f > python arbitrarily enforcing its own order. Python likes being explicit > about things like that. > > rail shafigulin wrote: >> >> Does anybody know if there is a way to make --help option to display >> options in alphabetical order? Right now it displays option

Re: [Tutor] optparse.OptionParser options in alphabetical order in help display

2012-12-18 Thread rail shafigulin
On Tue, Dec 18, 2012 at 8:13 PM, Steven D'Aprano wrote: > On 19/12/12 07:39, rail shafigulin wrote: > > I currently have it done this way. It just seems a bit odd that I have to >> arrange it manually. >> > > What's so special about alphabetical order? Woul

[Tutor] release a script with non-standard dependencies

2012-12-19 Thread rail shafigulin
I'm attempting to write a script with command-line arguments. Based on some reading I have done online and some advice from this mailing list I'm going to use docopt and schema modules. The problem I'm facing is that I'd like to be able to give this script to anyone who needs it by just using one f

[Tutor] Groups of mutually exclusive options

2014-04-21 Thread rail shafigulin
Does anybody know if there is a way to specify groups of mutually exclusive options using argparse module? Currently argpase allows to specify mutually exclusive options in the following way (taken from https://docs.python.org/release/3.4.0/library/argparse.html#argparse.ArgumentParser.add_mutuall

Re: [Tutor] Groups of mutually exclusive options

2014-04-21 Thread rail shafigulin
> > >> > Sorry, I didn't follow your example. Can you explain what you mean in > English? What would be the outcome if you succeeded? > What could the user do and not do? The idea is to use two groups of parameters. The user can use only one group of parameters. For example say I have a the scri