Re: Iteration over recursion?

2006-06-21 Thread Kay Schluehr
You might use a separate prime generator to produce prime factors. The factorize algorithm becomes quite simple and configurable by prime generators. For demonstration purposes I use the eratosthenes sieve. def eratosthenes(): memo = {} q = 2 while True: p = memo.pop(q, None)

Python SHA-1 as a method for unique file identification ? [help!]

2006-06-21 Thread EP
This inquiry may either turn out to be about the suitability of the SHA-1 (160 bit digest) for file identification, the sha function in Python ... or about some error in my script. Any insight appreciated in advance. I am trying to reduce duplicate files in storage at home - I have a large numbe

Re: Initializing a set from a list

2006-06-21 Thread Xiaolei
Sybren Stuvel wrote: > Xiaolei enlightened us with: > > from pylab import * > > You'd better not do that. Just use "import pylab". > > > If I remove the first line, I correctly get: > > > > [1, 2, 3, 3] > > > > set([1, 2, 3]) > > Pylab shadows the built-in set name, which is one of the reasons you

Re: Python SHA-1 as a method for unique file identification ? [help!]

2006-06-21 Thread Justin Ezequiel
EP wrote: > This inquiry may either turn out to be about the suitability of the > SHA-1 (160 bit digest) for file identification, the sha function in > Python ... or about some error in my script. > > This is on Windows XP. > > def hashit(pth): > fs=open(pth,'r').read() > sh=sha.new(fs).hex

Re: What is Expressiveness in a Computer Language

2006-06-21 Thread Anton van Straaten
Marshall wrote: > Joe Marshall wrote: > >>They *do* have a related meaning. Consider this code fragment: >>(car "a string") >>[...] >>Both `static typing' and `dynamic typing' (in the colloquial sense) are >>strategies to detect this sort of error. > > > The thing is though, that putting it tha

Re: Iteration over recursion?

2006-06-21 Thread Nick Maclaren
In article <[EMAIL PROTECTED]>, "Kay Schluehr" <[EMAIL PROTECTED]> writes: |> |> You might use a separate prime generator to produce prime factors. The |> factorize algorithm becomes quite simple and configurable by prime |> generators. For demonstration purposes I use the eratosthenes sieve. Th

Re: What is Expressiveness in a Computer Language

2006-06-21 Thread Pascal Costanza
David Hopwood wrote: > Pascal Costanza wrote: >> Rob Thorpe wrote: >>> Pascal Costanza wrote: Matthias Blume wrote: > Pascal Costanza <[EMAIL PROTECTED]> writes: > >> (slot-value p 'address) is an attempt to access the field 'address in >> the object p. In many languages, the n

Re: How to truncate/round-off decimal numbers?

2006-06-21 Thread per9000
Hi, just a thought: if you *always* work with "floats" with two decimals, you are in fact working with integers, but you represent them as a floats - confusing for the internal representation. So why not work with int(float * 100) instead? This way you only have to take care of roundoffs etc when

Re: How to truncate/round-off decimal numbers?

2006-06-21 Thread per9000
oops, should be something like this: "int / int" = "int / int, int % int" /per9000 -- http://mail.python.org/mailman/listinfo/python-list

wxStyledTextCtrl and sql syntax highlightning

2006-06-21 Thread pierre_py
Hi. I use wxPy version 2.4.2 for Python 2.3. Now I wanted to use the wxStyledTextCtrl for viewing (editing) of sql code. I have the following: self.__m_styled_text_ctrl = wxPython.stc.wxStyledTextCtrl( self, wx.NewId(), style=wxPython.wx.wxNO_FULL_REPAINT_ON_RESIZE

Re: dynamic inheritance

2006-06-21 Thread Michele Simionato
alf wrote: > I did not think about any particular problem, just thought it would be > cool to abstract out the base class. In fact you can do that in C++ (to > some extend) using templates and parameterizing the base class. Python is ways cooler than C++. This is a sensible use case where you may

Are any python-LVM bindings available?

2006-06-21 Thread Meta
I need to execute LVM operations from within python ... are there any packages containing direct bindings available or is forking a shell the only solution? Any thoughts would be much appreciated. cheers. -- http://mail.python.org/mailman/listinfo/python-list

Search substring in a string and get index of all occurances

2006-06-21 Thread Nico Grubert
Hi there, I would like to search for a substring in a string and get the index of all occurances. mystring = 'John has a really nice powerbook.' substr = ' ' # space I would like to get this list: [4, 8, 10, 17, 22] How can I do that without using "for i in mystring" which might be expens

Re: Python SHA-1 as a method for unique file identification ? [help!]

2006-06-21 Thread Tim Peters
[EP <[EMAIL PROTECTED]>] > This inquiry may either turn out to be about the suitability of the > SHA-1 (160 bit digest) for file identification, the sha function in > Python ... or about some error in my script It's your script. Always open binary files in binary mode. It's a disaster on Windows

Re: How to truncate/round-off decimal numbers?

2006-06-21 Thread jean-michel bain-cornu
> just a thought: if you *always* work with "floats" with two decimals, > you are in fact working with integers, but you represent them as a > floats - confusing for the internal representation. > > So why not work with int(float * 100) instead? This way you only have > to take care of roundoffs e

Re: Search substring in a string and get index of all occurances

2006-06-21 Thread Pierre Quentel
mystring = 'John has a really nice powerbook.' substr = ' ' # space pos = 0 indices = [] while True: i = mystring.find(substr,pos) if i==-1: break indices.append(i) pos = i+1 print indices > [4, 8, 10, 17, 22] Pierre -- http://mail.python.org/mailman/listinfo/python-lis

Re: wxStyledTextCtrl and sql syntax highlightning

2006-06-21 Thread jean-michel bain-cornu
> I have the following: > self.__m_styled_text_ctrl = wxPython.stc.wxStyledTextCtrl( > self, wx.NewId(), > style=wxPython.wx.wxNO_FULL_REPAINT_ON_RESIZE) > self.__m_styled_text_ctrl.SetLexer(wxPython.stc.wxSTC_LEX_SQL) > self.__m_styled_text_ctrl.SetP

Re: How to truncate/round-off decimal numbers?

2006-06-21 Thread Nick Maclaren
In article <[EMAIL PROTECTED]>, "per9000" <[EMAIL PROTECTED]> writes: |> |> just a thought: if you *always* work with "floats" with two decimals, |> you are in fact working with integers, but you represent them as a |> floats - confusing for the internal representation. No, you aren't - you are

Re: Python is fun (useless social thread) ;-)

2006-06-21 Thread Bruno Desthuilliers
BartlebyScrivener wrote: You know what are dicts, right ? That is, containers with keyword-access to values ? Then you probably have dicts with a known, defined structure, and functions working on it. What classes (and hence 00) gives you is a way to associate these functions wi

OT: wxPython GUI designer

2006-06-21 Thread Frithiof Andreas Jensen
"Don Taylor" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I find it easy to use sizers in > wxGlade. Just gave is a spin yesterday: How does on fix the size of layout; I can only manage to get sizers to distribute space evently amongst the fields, which is *not* what I want. -

Re: What is Expressiveness in a Computer Language

2006-06-21 Thread Torben Ægidius Mogensen
"Rob Thorpe" <[EMAIL PROTECTED]> writes: > Andreas Rossberg wrote: > > > No, variables are insignificant in this context. You can consider a > > language without variables at all (such languages exist, and they can > > even be Turing-complete) and still have evaluation, values, and a > > non-trivi

Re: Specifing arguments type for a function

2006-06-21 Thread Mike Duffy
Paolo Pantaleo wrote: > I have a function > > def f(the_arg): > ... > > and I want to state that the_arg must be only of a certain type > (actually a list). Is there a way to do that? I wrote a cool function decorator just for that purpose. It's posted on the Python Decorator Library at: http://w

Re: separation events

2006-06-21 Thread Bruno Desthuilliers
Ghido wrote: > Hi all, i'm writing a software with python and wxpython for manage the > quality/environmental/security system for the my factory. I want to > separate the gui structure from the events and database operations for > obtain a very modular software, for this reason i start to use > sql

Re: What is Expressiveness in a Computer Language

2006-06-21 Thread Andreas Rossberg
David Hopwood wrote: > > Oh, but it *does* make sense to talk about dynamic tagging in a statically > typed language. It even makes perfect sense to talk about dynamic typing in a statically typed language - but keeping the terminology straight, this rather refers to something like described in

Re: What is Expressiveness in a Computer Language

2006-06-21 Thread Rob Thorpe
Matthias Blume wrote: > "Rob Thorpe" <[EMAIL PROTECTED]> writes: > > > I think we're discussing this at cross-purposes. In a language like C > > or another statically typed language there is no information passed > > with values indicating their type. > > You seem to be confusing "does not have a

help() on stdout.closed

2006-06-21 Thread Pekka Karjalainen
Python 2.4.1 (#1, May 16 2005, 15:19:29) [GCC 4.0.0 20050512 (Red Hat 4.0.0-5)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from sys import stdout >>> help (stdout.closed) If I do this, it gives me help on the bool object. Also: >>> stdout.closed.__doc__

Re: What is Expressiveness in a Computer Language

2006-06-21 Thread Andreas Rossberg
Rob Thorpe wrote: > > I think this should make it clear. If I have a "xyz" in lisp I know it > is a string. > If I have "xyz" in an untyped language like assembler it may be > anything, two pointers in binary, an integer, a bitfield. There is no > data at compile time or runtime to tell what it

What's the best way to wrap a whole script in try..except?

2006-06-21 Thread Hari Sekhon
I want to wrap a whole script in try ... except. What is the best way of doing this? Consider the following: - try: import def notifyme(traceback): code to tell me there is a problem except Exception, traceback: notifyme(traceback) Would this code not work because i

Re: help() on stdout.closed

2006-06-21 Thread Jon Ribbens
In article <[EMAIL PROTECTED]>, Pekka Karjalainen wrote: from sys import stdout help (stdout.closed) > > If I do this, it gives me help on the bool object. stdout.closed is a bool. What were you expecting it to show you? -- http://mail.python.org/mailman/listinfo/python-list

Re: help() on stdout.closed

2006-06-21 Thread Fredrik Lundh
Pekka Karjalainen wrote: from sys import stdout help (stdout.closed) > > If I do this, it gives me help on the bool object. that's probably because "sys.stdout.closed" *is* a bool object: >>> sys.stdout.closed False >>> type(sys.stdout.closed) there's no way the reflection system can

Re: What's the best way to wrap a whole script in try..except?

2006-06-21 Thread Jon Ribbens
In article <[EMAIL PROTECTED]>, Hari Sekhon wrote: > I want to wrap a whole script in try ... except. What is the best way of > doing this? You could do this maybe: import sys def excepthook(exc_type, exc_value, tb): import modules_needed_to_notify_exception ... sys.excepthook =

Re: What's the best way to wrap a whole script in try..except?

2006-06-21 Thread Bruno Desthuilliers
Hari Sekhon wrote: > I want to wrap a whole script in try ... except. What is the best way of > doing this? > > Consider the following: - > > try: >import > > > >def notifyme(traceback): > code to tell me there is a problem > > except Exception, traceback: >notifyme(trac

Re: difference between import from mod.func() and x=mod.func()

2006-06-21 Thread Hari Sekhon
I take it that it's not worth listening to that tutorial and just using good old "import from", which I suspect is better anyway since it imports less..."uneducated premature optimisation" - I take it this is insulting a that programmer's progexuality...! "import from" it is then unless anybody has

Re: Search substring in a string and get index of all occurances

2006-06-21 Thread Fredrik Lundh
Nico Grubert wrote: > I would like to search for a substring in a string and get the index of > all occurances. > > mystring = 'John has a really nice powerbook.' > substr = ' ' # space > > I would like to get this list: > [4, 8, 10, 17, 22] the find and index methods take an optional start ar

Re: WinPops

2006-06-21 Thread Hari Sekhon
If you were going to do this you may as well just do something likeif sys.platform='win32':    os.system('net send ')elif sys.platform[:5]='linux'   os.system('smblcient -M etc...') This would be more portable and simpler than the alternatives I've seen. It would be better if there was just a cro

Re: wxStyledTextCtrl and sql syntax highlightning

2006-06-21 Thread pierre_py
Hi. Thanks it works now .. i must reset the default styles with StyleClearAll and then set the styles apropriate again. Is there a way that the keyword list isn't case sensitive, as sql isn't. reg, Pierre jean-michel bain-cornu wrote: > > I have the following: > > self.__m_styled_text_c

Re: memory error with zipfile module

2006-06-21 Thread Hari Sekhon
On 20/05/06, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: Roger Miller a écrit :> The basic problem is that the zipfile interface only reads and writes> whole files, so it may perform poorly or fail on huge files.   At one> time I implemented a patch to allow reading files in chunks. However I >

embedded Python calling app via COM

2006-06-21 Thread Jim
I have a C++ app which fires up a Python script using C API calls. That script operates the app via Automation calls, like this: from win32com.client import * from mywrapper import * myapp = Application() myapp.Visible = True mydoc = myapp.Documents.Open(...) My problem is to make sure the insta

Re: What is Expressiveness in a Computer Language

2006-06-21 Thread Joachim Durchholz
Andreas Rossberg schrieb: > Rob Thorpe wrote: >> Hmm. You're right, ML is no-where in my definition since it has no >> variables. > > Um, it has. Mind you, it has no /mutable/ variables, but that was not > even what I was talking about. Indeed. A (possibly nonexhaustive) list of program entitie

Re: What is Expressiveness in a Computer Language

2006-06-21 Thread Joachim Durchholz
Matthias Blume schrieb: > Joachim Durchholz <[EMAIL PROTECTED]> writes: > >> Matthias Blume schrieb: >>> Perhaps better: A language is statically typed if its definition >>> includes (or ever better: is based on) a static type system, i.e., a >>> static semantics with typing judgments derivable by

Re: How to truncate/round-off decimal numbers?

2006-06-21 Thread per9000
Nick Maclaren wrote: > |> just a thought: if you *always* work with "floats" with two decimals, > |> you are in fact working with integers, but you represent them as a > |> floats - confusing for the internal representation. > > No, you aren't - you are working with fixed-point Nick, your answer h

Re: What is Expressiveness in a Computer Language

2006-06-21 Thread Joachim Durchholz
Pascal Costanza schrieb: > (It's really important to understand that the idea is to use this for > deployed programs - albeit hopefully in a more structured fashion - and > not only for debugging. The example I have given is an extreme one that > you would probably not use as such in a "real-wor

Re: What's the best way to wrap a whole script in try..except?

2006-06-21 Thread Hari Sekhon
Jon Ribbens wrote: In article <[EMAIL PROTECTED]>, Hari Sekhon wrote: I want to wrap a whole script in try ... except. What is the best way of doing this? You could do this maybe: import sys def excepthook(exc_type, exc_value, tb): import modules_needed_to_not

Re: What is Expressiveness in a Computer Language

2006-06-21 Thread Chris Uppal
Anton van Straaten wrote: > But a program as seen by the programmer has types: the programmer > performs (static) type inference when reasoning about the program, and > debugs those inferences when debugging the program, finally ending up > with a program which has a perfectly good type scheme. I

Re: What is Expressiveness in a Computer Language

2006-06-21 Thread Chris Uppal
Darren New wrote: [me:] > > Personally, I would be quite happy to go there -- I dislike the idea > > that a value has a specific inherent type. > > Interestingly, Ada defines a type as a collection of values. It works > quite well, when one consistantly applies the definition. I have never been v

Re: What is Expressiveness in a Computer Language

2006-06-21 Thread Chris Uppal
David Hopwood wrote: > When people talk > about "types" being associated with values in a "latently typed" or > "dynamically typed" language, they really mean *tag*, not type. I don't think that's true. Maybe /some/ people do confuse the two, but I am certainly a counter-example ;-) The tag (if

Re: What is Expressiveness in a Computer Language

2006-06-21 Thread Chris Uppal
Chris Smith wrote: > > It would be interesting to see what a language designed specifically to > > support user-defined, pluggable, and perhaps composable, type systems > > would look like. [...] > > You mean in terms of a practical programming language? If not, then > lambda calculus is used in

Re: Iteration over recursion?

2006-06-21 Thread Tim Peters
[Kay Schluehr] > You might use a separate prime generator to produce prime factors. The > factorize algorithm becomes quite simple and configurable by prime > generators. Alas, yours was _so_ simple that it always takes time proportional to the largest prime factor of n (which may be n) instead of

Re: What's the best way to wrap a whole script in try..except?

2006-06-21 Thread Hari Sekhon
Jon Ribbens wrote: In article <[EMAIL PROTECTED]>, Hari Sekhon wrote: I want to wrap a whole script in try ... except. What is the best way of doing this? You could do this maybe: import sys def excepthook(exc_type, exc_value, tb): import modules_needed_to_not

Re: Search substring in a string and get index of all occurances

2006-06-21 Thread Maric Michaud
Another variant, I feel this one more natural as it doesn't contain a C-looking infinite loop (also I made it a generator but this is not the topic). In [160]: def indices(s, subs) : .: last = 0 .: for ind, part in in enumerate(s.split(subs)[:-1]) : .: yield

Re: help() on stdout.closed

2006-06-21 Thread Pekka Karjalainen
On 2006-06-21, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > have you tried things like [...] I have now. I'm not sure what the results are supposed to tell me, but I am not going to press the issue. Suppose I had no idea what sys.stdout.closed was and wanted to find out. Where would I look it up?

Re: help() on stdout.closed

2006-06-21 Thread Fredrik Lundh
Pekka Karjalainen wrote: > Suppose I had no idea what sys.stdout.closed was and wanted to find out. > Where would I look it up? >>> help(sys.stdout) ... | closed = | True if the file is closed ... in case anyone feels like hacking, support for something like >>> help(sys.stdout, "close

Re: help() on stdout.closed

2006-06-21 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Pekka Karjalainen wrote: > Suppose I had no idea what sys.stdout.closed was and wanted to find out. > Where would I look it up? `sys.stdout` is a file (like) object: http://docs.python.org/lib/bltin-file-objects.html Ciao, Marc 'BlackJack' Rintsch -- http://mai

Re: Iteration over recursion?

2006-06-21 Thread MTD
I've been testing my recursive function against your iterative function, and yours is generally a quite steady 50% faster on factorizing 2**n +/- 1 for 0 < n < 60. I think that, for a challenge, I'll try to make a recursive function that matche or beats the iterative function -- it's worth the exp

Re: Search substring in a string and get index of all occurances

2006-06-21 Thread Fredrik Lundh
Maric Michaud wrote: > Another variant, I feel this one more natural as it doesn't contain a > C-looking infinite loop doing things in a convoluted way because you think that non-infinite while- loops are not natural? you can get help for that, you know ;-) > Actually it's even more efficient t

Re: What is Expressiveness in a Computer Language

2006-06-21 Thread Rob Thorpe
> So, will y'all just switch from using "dynamically typed" to "latently > typed", and stop talking about any real programs in real programming > languages as being "untyped" or "type-free", unless you really are > talking about situations in which human reasoning doesn't come into > play? I think

Re: Search substring in a string and get index of all occurances

2006-06-21 Thread K.S.Sreeram
Maric Michaud wrote: > Actually it's even more efficient than Lundh's effbot's solution finds overlapping occurrences, whereas your solution finds non-overlapping occurrences. So efficiency comparisons are not valid. e.g: indices( 'a', 'aa' ) your solution gives: 0,2 effbots's solution: 0,1

urllib2 OpenerDirector question on usage.

2006-06-21 Thread Ant
Hello all, I am using urllib2 as a part of a web testing tool. One of the things I am testing is the effect of two different people perforing the same actions on the website - do they interfer with each other or not. So to emulate this, I essentially have the following function: def get_opener()

Re: Search substring in a string and get index of all occurances

2006-06-21 Thread Tim Chase
> I would like to search for a substring in a string and get the index of > all occurances. > > mystring = 'John has a really nice powerbook.' > substr = ' ' # space > > I would like to get this list: >[4, 8, 10, 17, 22] > > How can I do that without using "for i in mystring" which might b

Re: Segmentation fault only on Iinux

2006-06-21 Thread Kiran
Unfortunately (i guess), I am not doing any XML. However, I am taking the previous suggestion of putting print lines in every other line of my code and then seeing where it crashes. Hopefully, that will solve the problem. thanks for the suggestions everybody -- Kiran Frank Millman wrote: > Kira

Re: What's the best way to wrap a whole script in try..except?

2006-06-21 Thread Hari Sekhon
Hari Sekhon wrote: Jon Ribbens wrote: In article <[EMAIL PROTECTED]>, Hari Sekhon wrote: I want to wrap a whole script in try ... except. What is the best way of doing this? You could do this maybe: import sys def excepthook(exc_type, exc_value, tb

very strange bug coercing to Unicode: need string or buffer, int found

2006-06-21 Thread bussiere maillist
i truly didn't understand this error :Traceback (most recent call last):  File "D:\Programmation\FrancePaquet\FrancePaquet.py", line 77, in ?    cabtri = "zz" + chiffrescabtri + clefcTypeError: coercing to Unicode: need string or buffer, int found >>> if someone could help me i will be glad, this p

Re: What is Expressiveness in a Computer Language

2006-06-21 Thread Andreas Rossberg
Chris Uppal wrote: > > I have never been very happy with relating type to sets of values (objects, > whatever). Indeed, this view is much too narrow. In particular, it cannot explain abstract types, which is *the* central aspect of decent type systems. There were papers observing this as early

Re: Search substring in a string and get index of all occurances

2006-06-21 Thread bearophileHUGS
Maric Michaud: > I'd love str implement a xsplit(sub, start, end) method, so I could have > wrote : enumerate(s.xsplit(subs, 0, -1)). Some of such str.x-methods (or str.i-methods, etc) can be useful (especially for Py3.0), but keeping APIs simple and compact is very important, otherwise when you p

Re: What is Expressiveness in a Computer Language

2006-06-21 Thread Pascal Costanza
Joachim Durchholz wrote: > Pascal Costanza schrieb: >> (It's really important to understand that the idea is to use this for >> deployed programs - albeit hopefully in a more structured fashion - >> and not only for debugging. The example I have given is an extreme one >> that you would probably

Re: Search substring in a string and get index of all occurances

2006-06-21 Thread Maric Michaud
Le Mercredi 21 Juin 2006 14:01, Fredrik Lundh a écrit : > > Another variant, I feel this one more natural as it doesn't contain a > > C-looking infinite loop > > doing things in a convoluted way because you think that non-infinite while- > loops are not natural? you can get help for that, you know

Delivery reports about your e-mail

2006-06-21 Thread dpsp2004
-This message contained a computer virus which has been detected and deleted by the BT Business Email Virus Filter to avoid infecting your computer. - -You may wish to contact the sender of this email requesting they remove any virus infection from their PC before re-sending the email and attachm

Re: need all python dialog equivalent

2006-06-21 Thread Eric S. Johansson
[EMAIL PROTECTED] wrote: > dialog binary is 110 KB. Won't it fit ? missing library. I have ncurses and newt and dialog seems to require something called ncursesw. I've been trying to find the Python newt module as well and that seems to be as invisible as the creature it's named after. --

How to override the doc of an object instance.

2006-06-21 Thread David Huard
Hi, I'm not really sure about the right terminology, but here is my question, boiled down to this code: class widget (object): """This is a widget.""" def __init__(self): self._x = None def fget(self): return self._x def fset(self, value): self._x = value

Re: need all python dialog equivalent

2006-06-21 Thread Eric S. Johansson
Miki wrote: > Hello Eric, > >> Is there anything like an all Python dialog equivalent floating around? > http://www.pythonware.com/library/tkinter/introduction/ I'm sorry. I should have been more explicit. I need a textbased interface such as the ones you would get with curses and dialogue. -

Re: very strange bug coercing to Unicode: need string or buffer, int found

2006-06-21 Thread Max Erickson
"bussiere maillist" <[EMAIL PROTECTED]> wrote: > --=_Part_118629_1441854.1150895040355 > i truly didn't understand this error : > Traceback (most recent call last): > File "D:\Programmation\FrancePaquet\FrancePaquet.py", line 77, > in ? > cabtri = "zz" + chiffrescabtri + clefc > TypeE

Re: OS specific command in Python

2006-06-21 Thread diffuser78
I have a question on getpass. Since I am a newbie you might find it a little dumb. By using the getpass, are u trying to retrieve the username and password of remote mahcine or local ? Avell Diroll wrote: > [EMAIL PROTECTED] wrote: > > When you connect (via ssh or telnet) to a remote machine, y

Re: Search substring in a string and get index of all occurances

2006-06-21 Thread Fredrik Lundh
K.S.Sreeram wrote: > effbot's solution finds overlapping occurrences, whereas your solution > finds non-overlapping occurrences. So efficiency comparisons are not valid. oops. my bad. here's a fixed version: result = []; pos = 0 try: while 1: pos = mystring.index(su

Re: How to override the doc of an object instance.

2006-06-21 Thread Maric Michaud
Le Mercredi 21 Juin 2006 06:50, David Huard a écrit : > class widget (object): >     """This is a widget.""" >     def  __init__(self): >         self._x = None >     def fget(self): >         return self._x >     def fset(self, value): >         self._x = value >         print self._x, 'Ok' >    

Re: What is Expressiveness in a Computer Language

2006-06-21 Thread Matthias Blume
"Rob Thorpe" <[EMAIL PROTECTED]> writes: > Matthias Blume wrote: >> "Rob Thorpe" <[EMAIL PROTECTED]> writes: >> >> > I think we're discussing this at cross-purposes. In a language like C >> > or another statically typed language there is no information passed >> > with values indicating their typ

Re: OS specific command in Python

2006-06-21 Thread Jon Ribbens
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] wrote: >> So basically, instead of typing in on the command line argument I want >> to have it in a python program and let it do the action. > > Try exec() and execfile() from the standard library (IIRC) Ths os.spawn...() functions are likely to b

Re: very strange bug coercing to Unicode: need string or buffer, int found

2006-06-21 Thread Fredrik Lundh
"bussiere maillist" wrote: >i truly didn't understand this error : > Traceback (most recent call last): > File "D:\Programmation\FrancePaquet\FrancePaquet.py", line 77, in ? >cabtri = "zz" + chiffrescabtri + clefc > TypeError: coercing to Unicode: need string or buffer, int found hint:

Re: What is Expressiveness in a Computer Language

2006-06-21 Thread Matthias Blume
Joachim Durchholz <[EMAIL PROTECTED]> writes: > Matthias Blume schrieb: >> Joachim Durchholz <[EMAIL PROTECTED]> writes: >> >>> Matthias Blume schrieb: Perhaps better: A language is statically typed if its definition includes (or ever better: is based on) a static type system, i.e., a >

Re: How to override the doc of an object instance.

2006-06-21 Thread David Huard
On Wed, 21 Jun 2006 15:39:02 +0200, Maric Michaud wrote: > This is w.__class__.x.__doc__. Thanks, So in order to implement what I want, I should rather consider an ipython hack to print w.__class__.x.__doc__ when it exists, instead of w.x.__doc_ ? Does this makes sense or it will ruin the stand

Re: need all python dialog equivalent

2006-06-21 Thread Grant Edwards
On 2006-06-21, Eric S. Johansson <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: >> dialog binary is 110 KB. Won't it fit ? > > missing library. I have ncurses and newt and dialog seems to require > something called ncursesw. I've been trying to find the Python newt > module as well and

Re: Psyco performance

2006-06-21 Thread [EMAIL PROTECTED]
> > > Place all the code in a function. Even without psyco you might get > > > somewhat better performances then. And I doubt psyco can optimise code > > > that isn't in a function anyway. Another thing I wasn't considering is that the first call with psyco enabled might be slower. The 2nd time th

Re: OS specific command in Python

2006-06-21 Thread diffuser78
Hi Avell, I want to communicate using subprocess module but my task is a little different. May be you can guide me. I have a linux box, from where I remotely execute all the commands. The remote machine is windows machine. I installed an OpenSSH server for windows to send the shutdown command. I

Re: What is Expressiveness in a Computer Language

2006-06-21 Thread Joachim Durchholz
Chris Uppal schrieb: > Chris Smith wrote: >> I think Marshall got this one right. The two are accomplishing >> different things. In one case (the dynamic case) I am safeguarding >> against negative consequences of the program behaving in certain non- >> sensical ways. In the other (the static ca

Re: What is Expressiveness in a Computer Language

2006-06-21 Thread Joachim Durchholz
Matthias Blume schrieb: > Joachim Durchholz <[EMAIL PROTECTED]> writes: > >> Matthias Blume schrieb: >>> Joachim Durchholz <[EMAIL PROTECTED]> writes: >>> Matthias Blume schrieb: > Perhaps better: A language is statically typed if its definition > includes (or ever better: is based on

Re: What is Expressiveness in a Computer Language

2006-06-21 Thread Rob Thorpe
Matthias Blume wrote: > "Rob Thorpe" <[EMAIL PROTECTED]> writes: > > Matthias Blume wrote: > >> "Rob Thorpe" <[EMAIL PROTECTED]> writes: > >> > >> > I think we're discussing this at cross-purposes. In a language like C > >> > or another statically typed language there is no information passed > >>

Re: [OT] code is data

2006-06-21 Thread Anton Vredegoor
Bruno Desthuilliers wrote: > You mean like 'converting' javascript to python or python to ruby (or > converting any home-grown DSL to Python, etc) ? Yes, but also what some other posters mentioned, making Pythons internal parsing tree available to other programs (and to Python itself) by using

Re: What is Expressiveness in a Computer Language

2006-06-21 Thread Joachim Durchholz
Pascal Costanza schrieb: > Static type systems potentially change the semantics of a > language in ways that cannot be captured by dynamically typed languages > anymore, and vice versa. Very true. I also suspect that's also why adding type inference to a dynamically-typed language doesn't give

Remote Boot Manager Scripting (Python)

2006-06-21 Thread diffuser78
I just started to write a small project in Python. I was wondering if there can be something like remote boot manager. I have to remotely start a computer. It has dual boot (WinXP and Linux). My remote computer is Linux which will send command to remotely boot the other computer. Can we write pyt

Re: new python icons for windows

2006-06-21 Thread and-google
Istvan Albert wrote: > But these new icons are too large, too blocky and too pastel. Hooray! Glad to see *someone* doesn't like 'em, I'll expect a few more when b1 hits. :-) Although I can't really see 'large', 'blocky' or 'pastel'... they're the same size and shape as other Windows document ico

returning index of minimum in a list of lists

2006-06-21 Thread JJLaRocque
Hi all, Is there a simple python function to return the list index of the minimum entry in a list of lists? ie, for [[3,3,3,3], [3,3,3,1], [3,3,3,3]] to return 2,4. Or, same question but just for a list of numbers, not a list of lists. Thanks, Josh -- http://mail.python.org/mailman/listinfo/py

Re: How to override the doc of an object instance.

2006-06-21 Thread Paul McGuire
"David Huard" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Wed, 21 Jun 2006 15:39:02 +0200, Maric Michaud wrote: > > > This is w.__class__.x.__doc__. > > Thanks, > > So in order to implement what I want, I should rather consider an > ipython hack to print w.__class__.x.__doc__ w

Re: Search substring in a string and get index of all occurances

2006-06-21 Thread Fredrik Lundh
Tim Chase wrote: > >>> indicies = [i for i in xrange(len(mystring)) if > mystring.startswith(substr, i)] > >>> indicies > [4, 8, 10, 17, 22] > > is my preferred way of doing this. it's things like this that makes me wonder why I spent a week speeding up the string implementation for Python 2

Re: What is Expressiveness in a Computer Language

2006-06-21 Thread Marshall
Chris Smith wrote: > > When I used the word "type" above, I was adopting the > working definition of a type from the dynamic sense. That is, I'm > considering whether statically typed languages may be considered to also > have dynamic types, and it's pretty clear to me that they do. I suppose th

Re: What is Expressiveness in a Computer Language

2006-06-21 Thread Marshall
Joachim Durchholz wrote: > > Hmm... I think this distinction doesn't cover all cases. > > Assume a language that > a) defines that a program is "type-correct" iff HM inference establishes > that there are no type errors > b) compiles a type-incorrect program anyway, with an establishes > rigorous s

Re: need all python dialog equivalent

2006-06-21 Thread Fredrik Lundh
Eric S. Johansson wrote: > I'm creating a dialogue style interface for an application on a > dedicated system. All I have is basic Python 2.3. Is there anything > like an all Python dialog equivalent floating around? I'm currently > hacking away in curses but it's taking me a long way down w

Re: What is Expressiveness in a Computer Language

2006-06-21 Thread Matthias Blume
"Rob Thorpe" <[EMAIL PROTECTED]> writes: >> >> > No it doesn't. Casting reinterprets a value of one type as a value of >> >> > another type. >> >> > There is a difference. If I cast an unsigned integer 20 to a >> >> > signed integer in C on the machine I'm using then the result I will get

Re: What is Expressiveness in a Computer Language

2006-06-21 Thread David Hopwood
Rob Thorpe wrote: > Matthias Blume wrote: >>"Rob Thorpe" <[EMAIL PROTECTED]> writes: >> >>>I think we're discussing this at cross-purposes. In a language like C >>>or another statically typed language there is no information passed >>>with values indicating their type. >> >>You seem to be confusin

Re: What is Expressiveness in a Computer Language

2006-06-21 Thread Marshall
Joachim Durchholz wrote: > > On a semantic level, the tag is always there - it's the type (and > definitely part of an axiomatic definition of the language). > Tag elimination is "just" an optimization. I see what you're saying, but the distinction is a bit fine for me. If the language has no poss

Re: What is Expressiveness in a Computer Language

2006-06-21 Thread Marshall
David Hopwood wrote: > > Oh, but it *does* make sense to talk about dynamic tagging in a statically > typed language. > > That's part of what makes the term "dynamically typed" harmful: it implies > a dichotomy between "dynamically typed" and "statically typed" languages, > when in fact dynamic tag

Re: How to override the doc of an object instance.

2006-06-21 Thread Maric Michaud
Le Mercredi 21 Juin 2006 15:58, David Huard a écrit : > On Wed, 21 Jun 2006 15:39:02 +0200, Maric Michaud wrote: > > This is w.__class__.x.__doc__. > > Thanks, > > So in order to implement what I want, I should rather consider an > ipython hack to print w.__class__.x.__doc__ when it exists, instead

  1   2   3   >