Re: Getting externally-facing IP address?

2006-11-10 Thread Tim Williams
On 10/11/06, Tim Williams <[EMAIL PROTECTED]> wrote: > > > On 10/11/06, Michael B. Trausch <[EMAIL PROTECTED]> wrote: > > > > > > > > Every programming example that I have seen thus far shows simple server > code and how to bind to a socket--however

Re: string to list of numbers conversion

2006-11-10 Thread Tim Williams
On 5 Nov 2006 04:34:32 -0800, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Hi, > I have a string '((1,2), (3,4))' and I want to convert this into a > python tuple of numbers. But I do not want to use eval() because I do > not want to execute any code in that string and limit it to list of > num

Re: service windows avec py2exe

2006-11-12 Thread Tim Golden
DarkPearl wrote: > ok, > > It's this line who crash the service : > > self.WMIService > =win32com.client.GetObject(r"winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") > > > why this function goes when it is not a service? > > with IDLE -> ok > with py2exe executable (no windows service) -

RE: sqlite3 views, if not exists clause

2006-11-14 Thread Tim Golden
[Josh] | I'm running into a problem when trying to create a view in my sqlite | database in python. I think its a bug in the sqlite3 api that | comes with python 2.5. | THIS DOES NOT WORK, but it should! | conn = sqlite3.connect(':memory:') | conn.execute("create table foo (a int,b int)") |

Re: Is python for me?

2006-11-14 Thread Tim Chase
> By large I mean an application with intensive operations, such > as a fancy GUI maybe a couple of threads, accessing a > database, etc. I can't say I've had any python related problems on such matters. I've done some modestly large-sized apps, and the bottlenecks are almost always I/O bound...

Re: Yield

2006-11-16 Thread Tim Chase
>> I absoultely agree. Thanks for pointing me out to some real-world >> code. However, the function you pointed me to is not a generator >> (there is no yield statement... it just returns the entire list of >> primes). > > Oops, should have looked at the code more closely. Another example > wou

Re: Python v PHP: fair comparison?

2006-11-16 Thread Tim Chase
Demel, Jeff wrote: > Walterbyrd wrote: >> Okay, where can I get Python and Apache 2.X for $10 a year? > > Webfaction.com Um, I think you're off by an order of magnitude. Walterbyrd asked about $10/*year* and webfaction.com charges $7.50/*month*. Well, I suppose if one only needed one and a

Re: how to print pdf with python on a inkjet printer.

2006-11-16 Thread Tim Roberts
or is it that I will have to use the wxpython library asuming that >there is a print dialog which can open up the list of printers? Even if you got the list of printers, what would you do with it? -- Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: summarize text

2006-05-29 Thread Tim Chase
> does anyone know of a library which permits to summarise text? > i've been looking at nltk but haven't found anything yet. any > help would be very welcome. Well, summarizing text is one of those things that generally takes a brain-cell or two to do. Automating the process would require doing

Re: TIming

2006-05-29 Thread Tim Roberts
eed to be prepared to start your app if the time is just PAST 6 PM on June 13. -- - Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: TSV to HTML

2006-05-31 Thread Tim Chase
print "%s" % escape(item) It doesn't gracefully attempt to define headers using , , and sorts of rows, but a little toying should solve that. -tim -- http://mail.python.org/mailman/listinfo/python-list

Re: TIming

2006-05-31 Thread Tim Roberts
WIdgeteye <[EMAIL PROTECTED]> wrote: >On Tue, 30 May 2006 16:15:44 +1000, John McMonagle wrote: > >> Tim Roberts is right. As you are on linux, I suggest you investigate the >> at command - very user friendly and not at all complicated. > >I have been using Slac

RE: Is device Connected Windows?

2006-06-01 Thread Tim Golden
[placid] | Just wondering is there a way (not brute force) to check if a usb | storage device is connected? Hmmm. How do you identify "a usb storage device" to know that it is or isn't connected? You can certainly do something useful with wmi. eg, import wmi c = wmi.WMI () for usb_disk in c.W

Re: default argument values qns

2006-06-01 Thread Tim Chase
> i have declared a function like this: > > def aFunction ( arg1 , arg2 = 0): > > print type(arg2) > > when i try to print the type of arg2, it gives me 'str' > type..why is it not integer type, since i have declared > it as 0 ?? >>> def a(arg1, arg2=0): ... print

Re: os.walk trouble

2006-06-01 Thread Tim Chase
> but I am stuck with incorrect understanding of > os.walk. I've tried: > > root, dirs, files = os.walk(dirname) os.walk returns an iteratable sequence of those tuples. Thus, you want to have for filepath, dirs, files in os.walk(dirname): #you're looking at the "dirs" and "files" in fi

Re: An oddity in list comparison and element assignment

2006-06-01 Thread Tim Chase
> As to containers, would you say that envelope containing five $100 > bills is the same as an envelope containing a single $100 bill and 4 > xerox copies of it? If so, I'd like to engage in some envelope > exchanges with you :-) if len(set([bill.serialnumber for bill in envelope])) != len(envel

Re: An oddity in list comparison and element assignment

2006-06-01 Thread Tim Peters
[EMAIL PROTECTED] > ... > As I see it, reference copying is a very useful performance and memory > optimization. But I don't think it should undermine the validity of > assert(a==b) as a predictor of invariance under identical operations. So, as Alex said last time, Try concisely expressing

Re: Finding web host headers

2006-06-01 Thread Tim Chase
> Is there any way to fetch a website's host/version headers using > Python? >>> import httplib >>> conn = httplib.HTTPConnection("docs.python.org") >>> conn.connect() >>> conn.request("HEAD", "/") >>> response = dict([(k.lower(), v) for k,v in conn.getresponse()]) >>> conn.close() >>> serv

Re: Finding web host headers

2006-06-01 Thread Tim Chase
>> Is there any way to fetch a website's host/version headers using >> Python? > > >>> import httplib > >>> conn = httplib.HTTPConnection("docs.python.org") > >>> conn.connect() > >>> conn.request("HEAD", "/") > >>> response = dict([(k.lower(), v) for k,v in conn.getresponse()]) > >>> conn.c

Re: Member index in toples

2006-06-01 Thread Tim Chase
> I have a tuple like this: > > T = ("One","Two","Three","Four") > > Is there any built-in way to find what is the index of "Two" withouot > looping within the tuple? > > Is the same feature available for lists or dictionaries? Lists have a index() method. For the tuple, you can convert it t

Re: integer to binary...

2006-06-01 Thread Tim Chase
>>> for example I want to convert number 7 to 0111 so I can make some >>> bitwise operations... >> Just do it: >> > 7 & 3 >> 3 > 7 | 8 >> 15 > I know I can do that but I need to operate in every bit separeted. I suppose there might be other operations for which having them as strings cou

RE: win32com: how to connect to a specific instance of a running object?

2006-06-02 Thread Tim Golden
[ago] | Is it possible to use win32com.client to connect to a | specific instance | of a running application? In particular I am interested in finding the | instance of excel which has a particular spreadsheet opened | considering | that there might be more instances of excel running at the | s

Re: Open Source Charting Tool

2006-06-02 Thread Tim Churches
A.M wrote: > I can't browse to www.reporlab.org, but I found http://www.reportlab.com/ > which has a commercial charting product. Is that what you referring to? Typo in the URL. Try http://www.reportlab.org You should also have a look at http://matplotlib.sourceforge.net/ Tim

Re: integer to binary...

2006-06-03 Thread Tim Chase
> The fact that they impliment the xor operator is pretty much > proof that integers are stored in binary format -- xor is only > defined for binary numbers. Um...let's not use bad logic/proofs for evidencing this... >>> hasattr(set(), "__xor__") True :) -tkc -- http://mail.python.org/mail

Re: Using print instead of file.write(str)

2006-06-03 Thread Tim Roberts
>> >> to print: >> >> 0123456789 > >The reverse isn't true ??? > > print "".join(str(x) for x in range(10)) What he meant it that it is impossible to produce "0123456789" using 10 separate print statements, while it IS possible with 10 separate writes. -- - Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: wxpython wxgrid question

2006-06-03 Thread Tim Roberts
almost every behavior you might want. -- - Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: HOST - dreamhost.com / Liberality (Hosting, Basic Requirement)

2006-06-05 Thread Tim X
Joachim Durchholz <[EMAIL PROTECTED]> writes: > Ilias Lazaridis schrieb: >> crossposted to 5 groups, which are affected by this case. >> followup not applicable. > > Actually, in this case, yes. > >> It _seems_ that Mr. Xah Les's account was terminated by dreamhost.com >> because of >> a) the inab

Apologies for cross post [was Re: HOST - dreamhost.com / Liberality (Hosting, Basic Requirement)]

2006-06-05 Thread Tim X
My apologies for not trimming the long list of crossposted groups. I hit 'y' when thinking 'n'! Tim -- tcross (at) rapttech dot com dot au -- http://mail.python.org/mailman/listinfo/python-list

Re: Large Dictionaries

2006-06-05 Thread Tim Peters
[Scott David Daniels] >> For example, time timsort (Python's internal sort) on pre-sorted >> data; you'll find it is handled faster than random data. O(N) vs O(N log N), in fact. [Lawrence D'Oliveiro] > But isn't that how a reasonable sorting algorithm should behave? Less > work to do if the data

Re: Large Dictionaries

2006-06-05 Thread Tim Peters
[Jim Segrave] > Actually, presorted lists are not a bad case for heapsort - it's quite > immune to any existing order or lack thereof, Write a heapsort and time it. It's not a difference in O() behavior, but more memory movement is required for a sorted list because transforming the list into a m

Re: what are you using python language for?

2006-06-06 Thread Tim Chase
> 4) Miscellaneous other stuff like grabbing all of the comic > strips I like every day and putting them on a local web > page so I can read them all in one place I wonder how many other folks have done this too. It was my first pet Python project, converting a Java rendition of the sam

wddx problem with entities

2006-06-07 Thread Tim Arnold
rd() value of each character, of course it's clean. Do I have to replace numbered entities in the wddx file before I can wddx.load() it? thanks! --tim example program: --- from xml.marshal import wddx datastring = ''' The image file, gif/aperçu

Re: help to install MySQL-python module

2006-06-07 Thread Tim Chase
>> error: invalid Python installation: unable to open >> /usr/local/lib/python2.3/config/Makefile (No such file or >> directory) > > Ernesto, Where did the install put Python - the obvious > situation is that the Makefile is not where the install of > MySQL-Python thinks it is. Some binary distro

Re: creating and naming objects

2006-06-07 Thread Tim Chase
> def createStudent(): > foo = Student() > /add stuff > > Now, suppose that I want to create another Student. Do I need > to name that Student something other than foo? What happens > to the original object? If you want to keep the old student around, you have to keep a reference to i

Re: printing backslash

2006-06-07 Thread Tim Chase
> i want to print something like this > > |\| > > first i tried it as string > > a = "|\|" > > it prints ok > > but when i put it to a list > > a = ["|\|"] > > it gives me '|\\|' .there are 2 back slashes...i only want one.. how > can i properly escape it? > I have tried [r"|\|"] , [r'\\'] b

Re: follow-up to FieldStorage

2006-06-07 Thread Tim Roberts
#x27;t find something after another read through. On the other hand, 45 seconds with the source code shows that "class FieldStorage" has member functions called "keys()" and "has_key()". Use the source, Luke. To me, that's one of the big beauties of Python. -- - Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: Instead of saving text files i need as html

2006-06-08 Thread Tim Chase
> Is this what you mean? > > -begin- > import urllib > urlfile = open(r'c:\temp\url.txt', 'r') > for lines in urlfile: > try: > outfilename = lines.replace('/', '-') > urllib.urlretrieve(lines.strip('/n'), 'c:\\temp\\' \ > + outfilename.strip('\n')[7:] + '.html'

Re: wxpython: can't even create a Panel

2006-06-08 Thread Tim Chase
> def __init__(self, parent, title): > wx.Frame.__init__(self, parent, -1, title) > > panel = wx.Panel(self) It looks like a subtle difference between panel = wx.Panel(self) and panel = wx.Panel(self) As the error message states, there is no "self"

Re: Large Dictionaries

2006-06-08 Thread Tim Peters
[Tim Peters] >> ... >> O(N log N) sorting algorithms helped by pre-existing order are >> uncommon, unless they do extra work to detect and exploit >> pre-existing order. [Lawrence D'Oliveiro] > Shellsort works well with nearly-sorted data. It's basically a

RE: better Python IDE? Mimics Maya's script editor?

2006-06-09 Thread Tim Golden
[Steve Holden] | warpcat wrote: | > In Maya's mel script editor window, it's split into two sections. | > Bottom window you can enter commands (where your script lives), top | > window gives results. The thing I'm really used to is | highlighting X# | > of lines in the bottom window (little sni

Re: wddx problem with entities

2006-06-09 Thread Tim Arnold
"Tim Arnold" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I'm confused about why I get this error: > UnicodeError: ASCII encoding error: ordinal not in range(128) > > when I try to load a wddx file containing this string: >

Getting start/end dates given week-number

2006-06-09 Thread Tim Chase
I've been trying to come up with a good algorithm for determining the starting and ending dates given the week number (as defined by the strftime("%W") function). My preference would be for a Sunday->Saturday range rather than a Monday->Sunday range. Thus, >>> startDate, stopDate = weekBound

Re: Getting start/end dates given week-number

2006-06-09 Thread Tim Chase
> I think you missed %U format, since later you write: correct. I remember seeing something (a long while back) that had a Sunday-first format, but I must have missed it in my reading of "man strftime". > If you want to match %U: > > def weekBoundaries(year, week): > startOfYear = date(y

Re: math.pow(x,y)

2006-06-11 Thread Tim Peters
[Wojciech Muła] >> You have to use operator **, i.e. 34564323**456356 Or the builtin pow() instead of math.pow(). [Gary Herron] > That's not very practical. That computation will produce a value with > more than 3.4 million digits. Yes. > (That is, log10(34564323)*456356 = 3440298.) Python will

Combining The Best Of Python, Ruby, & Java??????

2006-06-12 Thread Tim Daneliuk
So it is claimed: http://www.infoq.com/news/Scala--combing-the-best-of-Ruby-;jsessionid=CC7C8366455E67B04EE5864B7319F5EC Has anyone taken a look at this that can provide a meaningful contrast with Python? -- Tim

Re: [*SPAM*] Python open proxy honeypot

2006-06-13 Thread Tim Williams
On 13/06/06, Alex Reinhart <[EMAIL PROTECTED]> wrote: > > Is running Python's built-in smtpd, pretending to accept and forward all > messages, enough to get me noticed by a spammer, or do I have to do > something else to "advertise" my script as an open proxy? This will get you noticed by crawlers

Re: curses module bug in windows python?

2006-06-14 Thread Tim Daneliuk
ot supported under Windows ... -- -------- Tim Daneliuk [EMAIL PROTECTED] PGP Key: http://www.tundraware.com/PGP/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Decimals

2006-06-14 Thread Tim Roberts
places, unless you print it out with a %.2f format. DECIMAL is an SQL thing. Unless the language has a native decimal type, it cannot possibly know how to display it in the same format as your SQL. -- - Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: USB support

2006-06-14 Thread Tim Roberts
"rodmc" <[EMAIL PROTECTED]> wrote: > >I need to write a program which can access the USB ports on Mac and >Linux, is there a library available for Python? The "stable" version of Libusb includes a Python binding. The version in development does not yet.

Re: curses module bug in windows python?

2006-06-14 Thread Tim Daneliuk
Erik Max Francis wrote: > Tim Daneliuk wrote: > >> Nope - this module is not supported under Windows ... > > There's at least one Python curses module for Windows: > > http://adamv.com/dev/python/curses/ > Sorry, I should have been more specific: AFAIK, cu

Re: newbe: tuple

2006-06-14 Thread Tim Chase
> ip = socket.gethostbyaddr(socket.gethostname()) > > ip then becomes a tuple and takes on three values. I am trying to pull the > value of ip[2] which when printed displays: > ['10.5.100.17']. > > I want this ip that is being returned, but I would like it as a string, > without the [' and ']. An

Re: convert floats to their 4 byte representation

2006-06-14 Thread Tim Chase
> s = "%"+str(size) + "X" > return (s % number).replace(' ', '0') While I don't have a fast and easy way to represent floats, you may want to tweak this to be return ("%0*X" % (size,number)) which will zero-pad the number in hex to "size" number of places in a single step.

Re: Python Help

2006-06-14 Thread Tim Chase
> I have recently downloaded Python 2.4.3 on Windows XP. The > program does not recongnize when I type in python:" name > 'python' is not defined". Please tell me how to correct this. Sounds like you don't have it in your path. In XP, use Win+Break to pull up your system properties (the same as

Re: code folding, a unique problem to python?

2006-06-15 Thread Tim Chase
> But my question is more general: is it possible to implement > code folding with Python given that it has no real block > delimiters? Or is this still a matter of which particular > editor/IDE you use? Yes, it is an editor thing. In Vim, it's as simple as :set foldmethod=indent and

Re: Numerics, NaNs, IEEE 754 and C99

2006-06-15 Thread Tim Peters
[Nick Maclaren] Firstly, a FAR more common assumption is that integers wrap in twos' complement - Python does not do that. [Grant Edwards] >>> It used to [Fredrik Lundh] >> for integers ? what version was that ? [Grant] > Am I remebering incorrectly? Mostly but not entirely. > Didn'

Re: a good programming text editor (not IDE)

2006-06-15 Thread Tim Chase
I recommend Vim. > I'm looking for suggestions for a good cross-platform text > editor Check. > (which the features for coding, such as syntax > highlighting, etc.) Check. > but not a full IDE with all the fancy jazz > (GUI developer, UML diagrams, etc.). Check. > Ideally, it would be someth

Re: list of polynomial functions

2006-06-15 Thread Tim Chase
> The `i` is the problem. It's not evaluated when the lambda > *definition* is executed but when the lambda function is > called. And then `i` is always == `n`. You have to > explicitly bind it as default value in the lambda definition: > > polys.append(lambda x, i=i: polys[i](x)*x) > >

Re: list of polynomial functions

2006-06-15 Thread Tim Chase
> Just to be a bit more explicit: > In code like: > def make_polys(n): > """Make a list of polynomial functions up to order n.""" > p = lambda x: 1 > polys = [p] > for i in range(n): > polys.append(lambda x: polys[i](x)*x) > i=3 > > Th

Re: a good programming text editor (not IDE)

2006-06-15 Thread Tim Daneliuk
s, and the doc was written in LaTeX using the dvi2stonetablets backend... -- -------- Tim Daneliuk [EMAIL PROTECTED] PGP Key: http://www.tundraware.com/PGP/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Need Help comparing dates

2006-06-15 Thread Tim Chase
> I am new to Python and am working on my first program. I am trying to > compare a date I found on a website to todays date. The problem I have > is the website only shows 3 letter month name and the date. > Example: Jun 15 No year, right? Are you making the assumption that the year is the curr

Re: a good programming text editor (not IDE)

2006-06-16 Thread Tim Chase
> No need to argue. I started with vim, and finally switched to > emacs less than one year later. Both are very-much-so good editors. I made the opposite switch from emacs to vim in less than a year. Both are good^Wgreat editors, so one's decision to use one over the other is more a matter of wo

Re: Need Help comparing dates

2006-06-17 Thread Tim Chase
> I will try to work through Tim's response. I tried using it > yesterday but I was really confused on what I was doing. I'll put my plug in for entering the code directly at the shell prompt while you're trying to grok new code or toy with an idea. It makes it much easier to see what is going

Re: PyObject_SetItem(..) *always* requires a Py_INCREF or not?

2006-06-17 Thread Tim Peters
[EMAIL PROTECTED] > I would think everytime you add an item to a list you must increase > reference count of that item. _Someone_ needs to. When the function called to add the item does the incref itself, then it would be wrong for the caller to also incref the item. > http://docs.python.org/api

Re: wxPython question

2006-06-17 Thread Tim Roberts
that, in the first example, you are given a wx.MenuItem object to work with, should you need it. The second example hides it. It is rarely necessary to access a wx.MenuItem directly, so this is not usually an issue. -- - Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: mapping None values to ''

2006-06-18 Thread Tim Chase
> i wish to map None or "None" values to "". > eg > a = None > b = None > c = "None" > > map( , [i for i in [a,b,c] if i in ("None",None) ]) > > I can't seem to find a way to put all values to "". Can anyone help? > thanks I'd consider this a VeryBadIdea(tm). However, given Python's introsp

RE: Check if a file is closed

2006-06-19 Thread Tim Golden
[EMAIL PROTECTED] | How to check if a file is closed? | | On Win32 you can call CreateFile with write and share write and if it | raises an error, the file is closed. | | How to do it in Python??? It's not clear whether you want a cross-platform Python-only solution. But if all you want is a wa

Re: Formatted string to object

2006-06-19 Thread Tim Chase
> Can you use strings or %s strings like in the above or > > aaa = 'string' > aaa.%s() % 'upper' > > Somehow? Looks like you want to play with the eval() function. >>> aaa = 'hello' >>> result = eval("aaa.%s()" % 'upper') >>> result 'HELLO' Works for your second example. May work on your f

Re: Need Help comparing dates

2006-06-19 Thread Tim Chase
> I kept getting a Python error for the following line: > > month = m[webMonth] > > I changed it to month = month_numbers[webMonth] > > and that did the trick. Sorry for the confusion. Often when I'm testing these things, I'll be lazy and create an alias to save me the typing. In this case,

Re: Calling every method of an object from __init__

2006-06-19 Thread Tim Chase
> Is there a simple way to call every method of an object from its > __init__()? > > For example, given the following class, what would I replace the > comment line in __init__() with to result in both methods being called? > I understand that I could just call each method by name but I'm looking

Re: USB support

2006-06-19 Thread Tim Roberts
ython 2.4, Libusb 0.1.12 and PyUSB 0.3.3 on an Intel >based mac. It is my understanding that OS/X does not support the /proc filesystem. Without /proc, libusb cannot operate. -- - Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: comparing of python GUI´s

2006-06-20 Thread Tim Chase
> plz tell me the benefit (or any data) of each gui (pyqt , pyqtk , > wxpython , tkinter ..) Well, as you can see pyqt, pyqtk, and wxpython must be far better than tkinter because they have python (or bits of python) in their names. In turn, you can also clearly determine that wxpython is bet

Re: need helping tracking down weird bug in cPickle

2006-06-20 Thread Tim Peters
[Carl J. Van Arsdall] > Hey everyone, cPickle is raising an ImportError that I just don't quite > understand. When that happens, the overwhelmingly most likely cause is that the set of modules on your PYTHONPATH has changed since the pickle was first created, in ways such that a module _referenced

Re: Iteration over recursion?

2006-06-20 Thread Tim Peters
[MTD] > I've been messing about for fun creating a trial division factorizing > function and I'm naturally interested in optimising it as much as > possible. > > I've been told that iteration in python is generally more > time-efficient than recursion. Is that true? Since you heard it from me to b

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: 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: 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: [newbie] Iterating a list in reverse ?

2006-06-21 Thread Tim Chase
> Python newbie: I've got this simple task working (in about ten > different ways), but I'm looking for the "favoured" and "most Python > like" way. > > Forwards I can do this > for t in listOfThings: > print t > > Now how do I do it in reverse? Then general process would be to use the r

Re: random.jumpahead: How to jump ahead exactly N steps?

2006-06-21 Thread Tim Peters
[Matthew Wilson] > The random.jumpahead documentation says this: > > Changed in version 2.3: Instead of jumping to a specific state, n steps > ahead, jumpahead(n) jumps to another state likely to be separated by > many steps.. > > I really want a way to get to the Nth value in a random

Re: Iteration over recursion?

2006-06-21 Thread Tim Peters
[MTD <[EMAIL PROTECTED]>] > 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. If you're still not skipping multiples of 3, that should account for most of it. > I think that, for

Re: Is Queue.Queue.queue.clear() thread-safe?

2006-06-22 Thread Tim Peters
[Russell Warren] > I'm guessing no, since it skips down through any Lock semantics, Good guess :-) It's also unsafe because some internal conditions must be notified whenever the queue becomes empty (else you risk deadlock). > but I'm wondering what the best way to clear a Queue is then. > > Ese

Re: Is Queue.Queue.queue.clear() thread-safe?

2006-06-22 Thread Tim Peters
[Russell Warren] >>> I'm guessing no, since it skips down through any Lock semantics, [Tim Peters] >> Good guess :-) It's also unsafe because some internal conditions must >> be notified whenever the queue becomes empty (else you risk deadlock). [Fredrik Lundh] &g

Re: Using SQLite3 with python 2.5 beta

2006-06-22 Thread Tim Heaney
omeplace unusual, you'll have to tell configure where they are. It's possible you have SQLite3 installed, but you lack the header. My system uses RPM, so I had to install both sqlite and sqlite-devel before building Python. The sqlite-devel package contains the header. I hope this helps, Tim -- http://mail.python.org/mailman/listinfo/python-list

Re: hard to explain for a french ;-)

2006-06-23 Thread Tim Chase
> As explained in this thread > http://mail.python.org/pipermail/python-list/2006-June/348241.html > what you try to do will never work because your attempts are > at using python on the client side and only javascript works > for that purpose. Sounds like an opportunity to write JSPython...writ

Re: Trouble including Python.h

2006-06-23 Thread Tim Roberts
52: error: expected declaration >specifiers before '__declspec' __declspec is a Microsoft extension. Are you trying to build the Visual C++ source with gcc? -- - Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: adad

2006-06-24 Thread Tim Golden
edoardo batini wrote: > dvsdfvsdfvsdfvsf Oh no. Not another question about permutations! TJG -- http://mail.python.org/mailman/listinfo/python-list

Re: array manipulation without for loops

2006-06-25 Thread Tim Chase
> I have two arrays that are of the same dimension but having 3 different > values: 255, 1 or 2. > I would like to set all the positions in both arrays having 255 to be > equal, i.e., where one array has 255, I set the same elements in the > other array to 255 and visa versa. Does anyone know how t

Re: Absolute noob to Linux programming needs language choice help

2006-06-25 Thread Tim Roberts
1987, but Python's history doesn't begin until the early 1990s, unless you're counting ABC as well. -- - Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python in HTML

2006-06-25 Thread Tim Roberts
quot;abcde" However, it is considered a security risk which is why it is no longer enabled by default. Plus, it will only work on systems that have it installed. -- - Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: Search String for Word

2006-06-26 Thread Tim Chase
> What's the best way to search a string for a particular word and get a > booleen value indicating whether it exists in the string or not? >>> substring = 'foo' >>> targetstring = 'blah foo bar' >>> substring in targetstring True >>> if substring in targetstring: print 'yup' yup http://docs.

Re: Get List of Classes

2006-06-26 Thread Tim Chase
> Is there a method or attribute I can use to get a list of > classes defined or in-use within my python program? I tried > using pyclbr and readmodule but for reason that is dogslow. Well, given that so much in python is considered a class, the somewhat crude code below walks an object/module a

Re: Search String for Word

2006-06-26 Thread Tim Williams
On 26 Jun 2006 08:24:54 -0700, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > And what if I want to search for an item in a tuple, is there a > similarly easy method? > > Tim Chase wrote: > > > What's the best way to search a string for a particular word and get

Re: Get List of Classes

2006-06-26 Thread Tim Chase
>> I couldn't find any nice method for determining if a >> variable referenced a module other than checking to see if >> that item had both a "__file__" and a "__name__" attribute. > > Why not : > > In [8]: import types, sys > > In [9]: isinstance(sys, types.ModuleType) > Out[9]: True Yes...this

Re: Beginner Programmer Question

2006-06-26 Thread Tim Chase
> bigone = 100 > > number = input("Whats the first number?") > number2 = input ("Whats the second number?") > nu3 = number+number2 > while nu3 < bigone: > print ("Not there yet, next number please") > > print "Finally there!" > > thats what i thought maybe it was...but after the first two nu

Re: Questions on Threading

2006-06-26 Thread Tim Peters
[j.c.sackett] > I'm using the threading module to accomplish some distributed processing on > a project, and have a basic (I hope) question that I can't find an answer to > elsewhere. > > I've noted that there's a lot of documentation saying that there is no > external way to stop a thread, True.

Re: languages with full unicode support

2006-06-28 Thread Tim Roberts
pport this) > >As far as i know, here's few other lang's status: > >C ? No. This is implementation-defined in C. A compiler is allowed to accept variable names with alphabetic Unicode characters outside of ASCII. -- - Tim Roberts, [EMAIL PROTECTED] Providenza & Boek

RE: handling unicode data

2006-06-29 Thread Tim Golden
[Filipe] | I've done some searching and settled for pymssql, but it's | not too late to change yet. Indeed, the good thing about the DBAPI-compatibility of such libraries is that you can often switch and switch about with no cost to you at all. (Believe me, I've done it). Sometimes there is a co

RE: Event notification system - where to start ?

2006-06-29 Thread Tim Golden
[EMAIL PROTECTED] | We have been asked to develop and application for a client that is a | 'notification" system. We would like to use python, but are | struggling to find the right starting point. Any suggestions, tips or | sample code would be appreciated. | | Application outline; [... sni

Re: Reddit broke - should have remained on Lisp?

2006-06-29 Thread Tim X
80s. In this example, choosing lisp saved a development project which was looking very much like it was going to be a complete failure. If do something like selecting a different language saves a development project, isn't it also reasonable to suggest that the converse could be true and that

Re: String Question

2006-06-30 Thread Tim Roberts
post them. That will get an "invalid \x escape". \x must be followed by exactly two hex digits. You can't build up an escape sequence like this. -- - Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: finding the last file created in a directory

2006-06-30 Thread Tim Chase
> I have a repeatedly running process, which always creates a > new logfile with an ending n+1. What I need is to find the > last file, the one with highest number at the end. The problem > is, that the max() method gives me a wrong answer. I tried to > convert the items in my list into integers us

<    29   30   31   32   33   34   35   36   37   38   >