Re: [Tutor] Vista UAC

2009-09-10 Thread Jeff Johnson
Dj Gilcrease wrote: I have a python app that requires elevated privileges on Vista when installed in "Program Files" since it has an auto updater. I was wondering if there was a way with a standard install of python 2.6 that I can check if I have the correct privileges and if not relaunch the app

Re: [Tutor] Vista UAC

2009-09-10 Thread Alan Gauld
"Dj Gilcrease" wrote wondering if there was a way with a standard install of python 2.6 that I can check if I have the correct privileges and if not relaunch the app required privileges. I haven't checked what the standard os functions do on Windows but you can always use ctypes to access t

Re: [Tutor] web2py vs django

2009-09-10 Thread Mal Wanstall
On Thu, Sep 10, 2009 at 5:29 AM, Alan Gauld wrote: > > "Kent Johnson" wrote >> >> That thread is about web.py, not web2py, they are different frameworks. > > I confess I too had missed that subtlety! > Like editors and standards... > The wonderful thing about Web Frameworks in Python - there are

Re: [Tutor] Poorly understood error involving class inheritance

2009-09-10 Thread David Perlman
Yeah, this seems to be the best answer in this situation. :) On Sep 10, 2009, at 4:17 PM, Kent Johnson wrote: I would skip the cleverness of trying to subclass string. You can use str(z).rjust(20) as above, or use string formatting: '%20s' % z -- -dave---

Re: [Tutor] Poorly understood error involving class inheritance

2009-09-10 Thread Kent Johnson
On Thu, Sep 10, 2009 at 4:51 PM, David Perlman wrote: > Well, here's what I am really doing: > > class oneStim(str): >    def __init__(self, time, mods=[], dur=None, format='%1.2f'): >        self.time=time >        self.mods=mods >        self.dur=dur >        self.format=format This is a bit od

Re: [Tutor] Poorly understood error involving class inheritance

2009-09-10 Thread christopher . henk
tutor-bounces+christopher.henk=allisontransmission@python.org wrote on 09/10/2009 04:13:23 PM: > I'm not sure why I'm getting an error at the end here: > > >>> class dummy: > ... def __init__(self,dur=0): > ... self.dur=dur > ... > >>> z=dummy(3) > >>> z.dur > 3 > >>> z=d

Re: [Tutor] Poorly understood error involving class inheritance

2009-09-10 Thread Serdar Tumgoren
> When you sub "int" for "str", it seems to work. Is there a reason > you're not just subclassing "object"? I believe doing so would give > you the best of both worlds. > Of course, I should qualify the above -- the "str" subclass inherits very different methods than "int" or "object". http://doc

Re: [Tutor] Poorly understood error involving class inheritance

2009-09-10 Thread David Perlman
Well, here's what I am really doing: class oneStim(str): def __init__(self, time, mods=[], dur=None, format='%1.2f'): self.time=time self.mods=mods self.dur=dur self.format=format def __cmp__(self,other): return cmp(self.time,other.time) def _

Re: [Tutor] Poorly understood error involving class inheritance

2009-09-10 Thread Serdar Tumgoren
class dummy2(str): > ...     def __init__(self,dur=0): > ...             self.dur=dur > ... z=dummy2(3) z.dur > 3 > > So far so good.  But: > z=dummy2(dur=3) > Traceback (most recent call last): >  File "", line 1, in > TypeError: 'dur' is an invalid keyword argument for this f

[Tutor] Poorly understood error involving class inheritance

2009-09-10 Thread David Perlman
I'm not sure why I'm getting an error at the end here: >>> class dummy: ... def __init__(self,dur=0): ... self.dur=dur ... >>> z=dummy(3) >>> z.dur 3 >>> z=dummy(dur=3) >>> z.dur 3 That worked fine, of course. >>> class dummy2(str): ... def __init__(self,dur=0): ...

Re: [Tutor] (no subject)

2009-09-10 Thread Alan Gauld
"Dirk Wangsadirdja" wrote I tested it and it works. But I dont understand why it works. Can someone please explain it further? Thanks. ~n means the bitwise complement (or inverse) of n. This simply means reversing every bit of n so that 1-> 0 and 0->1 This trick relies on the fact that nega

[Tutor] Vista UAC

2009-09-10 Thread Dj Gilcrease
I have a python app that requires elevated privileges on Vista when installed in "Program Files" since it has an auto updater. I was wondering if there was a way with a standard install of python 2.6 that I can check if I have the correct privileges and if not relaunch the app required privileges.

Re: [Tutor] Getting list of attributes from list of objects

2009-09-10 Thread Douglas Philips
On or about 2009 Sep 10, at 11:36 AM, Serdar Tumgoren indited: I think a list comprehension might be the most compact way to accomplish what you're after: objcts = [a, b, c] titles = [obj.title for obj in objcts] That probably is the best form. For the sake of showing other options: from o

Re: [Tutor] Getting list of attributes from list of objects

2009-09-10 Thread Serdar Tumgoren
> I have the following list > > l= [ a, b, c] > > Where a,b,c are objects created from one class, e.g. each has title > attribute. > What I want to have is a list of titles, e.g. [a.title, b.title, c.title] > > Is there a quick way to do it? Or I should use loops (looping through each > element, an

Re: [Tutor] Getting list of attributes from list of objects

2009-09-10 Thread vince spicer
On Thu, Sep 10, 2009 at 8:51 AM, Oleg Oltar wrote: > Hi! > > I have the following list > > l= [ a, b, c] > > Where a,b,c are objects created from one class, e.g. each has title > attribute. > What I want to have is a list of titles, e.g. [a.title, b.title, c.title] > > Is there a quick way to do

[Tutor] Getting list of attributes from list of objects

2009-09-10 Thread Oleg Oltar
Hi! I have the following list l= [ a, b, c] Where a,b,c are objects created from one class, e.g. each has title attribute. What I want to have is a list of titles, e.g. [a.title, b.title, c.title] Is there a quick way to do it? Or I should use loops (looping through each element, and generating

Re: [Tutor] (no subject)

2009-09-10 Thread Kent Johnson
On Thu, Sep 10, 2009 at 9:54 AM, shellc...@juno.com wrote: > I want to display all the cards in a deck of playing cards using two tuples > for all the possible suits. > > > > value = ("A","2","3","4","5","6","7","8","9","10","J","Q","K") > > suit = ("c","h","s","d") > > deck = value[0:1] + suit[0

Re: [Tutor] wxpython question

2009-09-10 Thread Kristina Ambert
Thank you guys for the replies! And thanks for the headsup about the wxpython mail list, I'll be sure to sign up there as well. On Wed, Sep 9, 2009 at 7:14 PM, Alan Gauld wrote: > "Kristina Ambert" wrote > > I'm not sure if I could ask questions about wx in this list or not, >> hopefully it's

[Tutor] (no subject)

2009-09-10 Thread shellc...@juno.com
I want to display all the cards in a deck of playing cards using two tuples for all the possible suits. value = ("A","2","3","4","5","6","7","8","9","10","J","Q","K") suit = ("c","h","s","d") deck = value[0:1] + suit[0:1] for item in deck: print item This is the display >>> A c

Re: [Tutor] Threads very simple examle

2009-09-10 Thread Kent Johnson
On Thu, Sep 10, 2009 at 4:13 AM, Oleg Oltar wrote: > Hi! > > I have a question. > I want to create simple load test for my web application. > > Consider the following script: > > while 1: >     urllib2.urlopen("www.example.com") > > How can I make it running in several threads? Have you read at a

Re: [Tutor] web2py vs django

2009-09-10 Thread mdipierro
This is an example of a Django tutorial "polls" being rewritten in web2py. Hope to help kickstart: http://vimeo.com/6507384 -- View this message in context: http://www.nabble.com/web2py-vs-django-tp25360012p25376004.html Sent from the Python - tutor mailing list archive at Nabble.com.

Re: [Tutor] Threads very simple examle

2009-09-10 Thread Oleg Oltar
On Thu, Sep 10, 2009 at 12:43 PM, Alan Gauld wrote: > "Oleg Oltar" wrote > > I want to create simple load test for my web application. >> Consider the following script: >> >> while 1: >> urllib2.urlopen("www.example.com") >> > > Just a small caveat. > If you try a load test like this from a si

Re: [Tutor] (no subject)

2009-09-10 Thread Lucas Prado Melo
On Thu, Sep 10, 2009 at 6:44 AM, Dirk Wangsadirdja wrote: > I tested it and it works. But I dont understand why it works. Can someone > please explain it further? Thanks. ~i == -i - 1 http://en.wikipedia.org/wiki/Two%27s_complement ___ Tutor maillist

Re: [Tutor] (no subject)

2009-09-10 Thread Dirk Wangsadirdja
I tested it and it works. But I dont understand why it works. Can someone please explain it further? Thanks. Alan Gauld wrote: "C or L Smith" wrote Or (and I'll duck after I pass on what I just happened across today on the web): ### for i in range(len(word)): print word[~i] ### Neat

Re: [Tutor] Threads very simple examle

2009-09-10 Thread Alan Gauld
"Oleg Oltar" wrote I want to create simple load test for my web application. Consider the following script: while 1: urllib2.urlopen("www.example.com") Just a small caveat. If you try a load test like this from a single PC you might get very surprising (and non representative) results.

[Tutor] Threads very simple examle

2009-09-10 Thread Oleg Oltar
Hi! I have a question. I want to create simple load test for my web application. Consider the following script: while 1: urllib2.urlopen("www.example.com") How can I make it running in several threads? ___ Tutor maillist - Tutor@python.org To un

Re: [Tutor] (no subject)

2009-09-10 Thread Alan Gauld
"C or L Smith" wrote Or (and I'll duck after I pass on what I just happened across today on the web): ### for i in range(len(word)): print word[~i] ### Neat trick! Now what does ~ do?... the bitwise inverse. So it relies on the rules of complementing the binary value to effectively add