Re: how can I avoid abusing lists?

2006-07-07 Thread Ant
Rob Cowie wrote: > Just forget the lists... > counters = {0:0, 1:0, 2:0, 3:0, 4:0} Or perhaps just use a list: >>> counters = [0,0,0,0] >>> def inc(v): ... counters[v] += 1 ... >>> inc(1) >>> inc(1) >>> inc(3) >>> counters [0, 2, 0, 1] > The increment function should probably include a try:..

Re: language design question

2006-07-10 Thread Ant
>- why is len() not a member function of strings? Instead one says len(w). Coming from a Java background, I also thought this a weird setup. However IMHO there is another good reason to have len(obj) as we do in Python: it helps to enforce some sort of uniformity across code. If I want to fi

Re: Accessors in Python (getters and setters)

2006-07-10 Thread Ant
mystilleef wrote: > I decided to change the name of an attribute. Problem is I've used the > attribute in several places spanning thousands of lines of code. If I > had encapsulated the attribute via an accessor, I wouldn't need to do > an unreliable and tedious search and replace accross several

Re: mod_python fails to load under wamp

2006-07-10 Thread Ant
> "The Apache service named Apache.exe reported the following error: > >>> Cannot load c:/wamp/apache/modules/mod_python.so into server: (126) The > >>> specified module could not be found: <<< > before the error.log file could be opened." I have just had a similar problem (same error message),

Re: eval to dict problems NEWB going crazy !

2006-07-10 Thread Ant
> As Fredrik points out, embedded Python isn't the same as running > untrusted code. The reality is, Python has not been designed for running > untrusted code safely. So how do python app's typically embed python? For example things like Zope and idle are scripted using Python - presumably they r

Re: mod_python fails to load under wamp

2006-07-11 Thread Ant
> I suggest you search the download files on Xampp's sourceforge site and > look for an older version with Apache 2.0.55 . I'm not sure, but I > think xampp version 1.5.1 will be ok I did this just a few days ago, you could be right, but version 1.5.1 had no release notes, and a dodgy release num

Re: mod_python fails to load under wamp

2006-07-11 Thread Ant
> Uh... this may sound silly, but aren't .so files UNIX/Linux/Solaris > "shared object" files... Yes, but apache uses them (or at least the same file extension) for modules on Windows and Linux, so mod_python.so is correct. -- http://mail.python.org/mailman/listinfo/python-list

Abuse of the object-nature of functions?

2006-07-11 Thread Ant
Hi all, In a framework I've written to test out website, I use something like the following to add functionality at various points: #--- def do_work(callable, data): assertion = False try: assertion = callable.is_assertion except: pass

Re: Abuse of the object-nature of functions?

2006-07-11 Thread Ant
Sybren wrote: > Try to make a habit out of catching only the exceptions you know will > be thrown. Yes - you are right of course - this was just a minimal example of course to illustrate the sort of thing I'm using function attriutes for. Fredrik Lundh wrote: > Peter Otten wrote: > > assertion =

Re: Best Practices for Python Script Development?

2006-08-25 Thread Ant
> `Pydoc `_ seems to be > built around modules and I want to document scripts. Any python script *is* a python module. So pydoc is what you are after here. > Version Control > === Subversion and Trac are a very good combination - Trac is

Re: How to run Python file?

2006-09-02 Thread Ant
zefciu wrote: > Pontus Ekberg wrote: ... > > $ python test.py > > > > or > > > > $ ./test.py (if test.py is executable) > > > > > Thats if you use un*x. If you word under windows, the first would work, As would: > test.py Assuming python grabbed the .py extensions correctly (which it shouold h

Re: Negation in regular expressions

2006-09-08 Thread Ant
Steve Holden wrote: > George Sakkis wrote: > > It's always striked me as odd that you can express negation of a single > > character in regexps, but not any more complex expression. Is there a > > general way around this shortcoming ? The whole point of regexes is that they define expressions to

Re: Negation in regular expressions

2006-09-08 Thread Ant
> >>> re.split(r'@#', s) > ['', ' This ', ' is a ', '', ' test '] > >>> [g.group(1) for g in re.finditer(r'(.*?)(?:@#|$)', s)] > ['', ' This ', ' is a ', '', ' test ', ''] If it's duplicating the behaviour of split, but returning an iterator instead, how about avoiding hacking around with messy re

Re: Looking for a regexp generator based on a set of known string representative of a string set

2006-09-08 Thread Ant
[EMAIL PROTECTED] wrote: > Hello > > I am looking for python code that takes as input a list of strings > (most similar, > but not necessarily, and rather short: say not longer than 50 chars) > and that computes and outputs the python regular expression that > matches > these string values (not ne

Re: efficient text file search.

2006-09-11 Thread Ant
noro wrote: > Is there a more efficient method to find a string in a text file then: > > f=file('somefile') > for line in f: > if 'string' in line: > print 'FOUND' break ^^^ Add a 'break' after the print statement - that way you won't have to read the entire

Re: RELEASED Python 2.5 (release candidate 2)

2006-09-13 Thread Ant
Anthony Baxter wrote: ... > code in 2.5 before the final release. *Please* try this > release out and let us know about any problems you find. Not a problem with the release, but with the docs. I've just ported a module using the ElementTree package to 2.5, and the Module Index (http://docs.pytho

Re: Looking for the Perfect Editor

2006-09-14 Thread Ant
Jay wrote: > I, too, am a hardcore fan of jEdit. It's nice to finally see some user > support on this forum. :-) I quite often throw in jEdits name in these discussions. It's the most powerful and extensible editor I know of outside of the emacs/vi world (and far more accessible than those). -

Re: Looking for the Perfect Editor

2006-09-14 Thread Ant
Roger wrote: ... > The biggest problem I have with anything written in Java is the long > startup time. The editor may be great but the platform is mediocre. The startup time is one of the main reasons I have started to use vim more than jEdit. That and the fact that I currently have to work on

Re: RELEASED Python 2.5 (release candidate 2)

2006-09-15 Thread Ant
Georg Brandl wrote: > Georg Brandl wrote: ... > > Please open a bug in the tracker at http://www.sf.net/projects/python. > > Wait, don't bother - just fixed it myself. Nice one, cheers! -- http://mail.python.org/mailman/listinfo/python-list

Re: How to efficiently proceed addition and subtraction in python list?

2006-09-19 Thread Ant
Tim Chase wrote: > > I have a list AAA = [1, 2, 3] and would like to subtract one from list > > AAA > > so AAA' = [0, 1, 2] > > > > What should I do? > > > Sounds like a list comprehension to me: Also the built in function 'map' would work: >>> a = [1,2,3] >>> b = map(lambda x: x-1, a) >>> b [0,

Re: How to efficiently proceed addition and subtraction in pythonlist?

2006-09-19 Thread Ant
Steve Holden wrote: > Fredrik Lundh wrote: > > Steve Holden wrote: > > ... > """if performance is *really* important, you > need to benchmark both options""" Fair point. -- http://mail.python.org/mailman/listinfo/python-list

Re: Request for elucidation: enhanced generators

2006-09-20 Thread Ant
Ben Sizer wrote: ... > But do you have an example of such a use case? That's what I'm missing > here. I've been looking at this myself, trying to understand the point of coroutines. I believe that they boil down to generators which are able to take in data as well as provide it. A simple way of l

Re: Python regular expression question!

2006-09-20 Thread Ant
unexpected wrote: > > \b matches the beginning/end of a word (characters a-zA-Z_0-9). > > So that regex will match e.g. MULTX-FOO but not MULTX-. > > > > So is there a way to get \b to include - ? No, but you can get the behaviour you want using negative lookaheads. The following regex is effecti

Re: I need some help with a regexp please

2006-09-22 Thread Ant
John Machin wrote: ... > A little more is unfortunately not enough. The best advice you got was > to use an existing e-mail address validator. We got bitten by this at the last place I worked - we were using a regex email validator (from Microsoft IIRC), and we kept having problems with specific

Re: Don't use regular expressions to "validate" email addresses (was: I need some help with a regexp please)

2006-09-22 Thread Ant
Ben Finney wrote: ... > The best advice I've seen when people ask "How do I validate whether > an email address is valid?" was "Try sending mail to it". There are advantages to the regex method. It is faster than sending an email and getting a positive or negative return code. The delay may not b

Re: I need some help with a regexp please

2006-09-22 Thread Ant
John Machin wrote: > Ant wrote: > > John Machin wrote: > > ... > > > A little more is unfortunately not enough. The best advice you got was > > > to use an existing e-mail address validator. > > > > We got bitten by this at the last place I worked - we

Re: storing variable names in a list before they are used?

2006-09-29 Thread Ant
John Salerno wrote: > If I want to have a list like this: > > [(first_name, 'First Name:'), (last_name, 'Last Name:').] > > where the first part of each tuple is a variable name and the second ... > can't leave them as above, but if I put them in as a string, then how do > I later "transform"

Re: creating a small test server on my local computer

2006-09-30 Thread Ant
Mirco Wahab wrote: > Thus spoke John Salerno (on 2006-09-29 21:13): ... > My advice would be (because Apache installations on > WinXP don't usually support Python (except pulling > the whole thing into each CGI invocation) - download > and install a VMWare Player This sounds a horribly complicate

Re: File I/O

2006-09-30 Thread Ant
Kirt wrote: ... > i dont wanna parse the xml file.. > > Just open the file as: > > f=open('test.xml','a') > > and append a line "abc" before tag The other guys are right - you should look at something like ElementTree which makes this sort of thing pretty easy, and is robust. But if you are sur

Re: The Python world tries to be polite [formerly offensive to another language]

2006-10-01 Thread Ant
Mirco Wahab wrote: > Thus spoke A.M. Kuchling (on 2006-09-30 19:26): > > On Sat, 30 Sep 2006 09:10:14 +0100, > > Steve Holden <[EMAIL PROTECTED]> wrote: > Thats it. What is the fuzz all about? I consider 'hyper fatarrow' > (you did't the »=>« get right) just a joke of LW > (he does so sometimes ;

Re: loop beats generator expr creating large dict!?

2006-10-03 Thread Ant
George Young wrote: ... > I am puzzled that creating large dicts with an explicit iterable of > key,value pairs seems to be slow. I thought to save time by doing: > >palettes = dict((w,set(w)) for w in words) > > instead of: > >palettes={} >for w in words: > palettes[w]=set(w)

Re: re.match -- not greedy?

2006-11-22 Thread Ant
EXI-Andrews, Jack wrote: > the '*' and '+' don't seem to be greedy.. they will consume less in > order to match a string: > > >>> import re;re.match('(a+)(ab)','aaab').groups() > ('aa', 'ab') > > this is the sort of behaviour i'd expect from >'(a+?)(ab)' > > a+ should greedily consume a's at

Pyparsing Question.

2006-11-22 Thread Ant
I have a home-grown Wiki that I created as an excercise, with it's own wiki markup (actually just a clone of the Trac wiki markup). The wiki text parser I wrote works nicely, but makes heavy use of regexes, tags and stacks to parse the text. As such it is a bit of a mantainability nightmare - addin

Re: Pyparsing Question.

2006-11-23 Thread Ant
> Welcome to pyparsing! The simplest way to implement a markup processor in > pyparsing is to define the grammar of the markup, attach a parse action to > each markup type to convert the original markup to the actual results, and > then use transformString to run through the input and do the conv

Invoking Python from Cygwin problem.

2006-11-24 Thread Ant
Hi all, Using cygwin and Python 2.5, I have the following scripts, one bash script and the other a python script: --- #!/bin/bash TEST_VAR=`./test.py` TEST_VAR2=Test2 echo "Test var: $TEST_VAR OK" echo "Test var2: $TEST_

Re: Invoking Python from Cygwin problem.

2006-11-25 Thread Ant
Marc 'BlackJack' Rintsch wrote: ... > It's a feature. The `sys.stdout` object remembers if the last ``print`` > ended in a comma (see the `sys.stdout.softspace` attribute) and when the > interpreter executes its shutdown code and that `softspace` attribute is > set, an extra '\n' is printed. So

Re: Invoking Python from Cygwin problem.

2006-11-25 Thread Ant
Cousin Stanley wrote: ... > Using Cygwin and Python 2.4 under Win2K the following version > of your code seems to work OK here with no extraneous CR Hmm. Just tried it here at home (Python 2.5) and it works fine as well... Cygwin was pre-installed on my machine when I started work at the

Re: Why are slice indices the way they are in python?

2006-11-30 Thread Ant
Steve Bergman wrote: ... > Why? It doesn't seem intuitive to me. To me, it makes it harder, not > easier, to work with slices than if indexing started at 1 and the > above expression got you the 2nd throught the 5th character. Dijkstra has an article about this: http://www.cs.utexas.edu/users

Printing unix Line endings from Windows.

2006-12-04 Thread Ant
Hi all, I've got a problem here which has me stumped. I've got a python script which does some text processing on some files and writes it back out to the same file using the fileinput module with inplace set to True. The script needs to run from Windows, but the files need to be written with Uni

Re: Printing unix Line endings from Windows.

2006-12-05 Thread Ant
Larry Bates wrote: > Ant wrote: ... > > Is there any way of doing this without having to post-process the file > > in binary mode (a-la the crlf.py script) ... > You can write to a new file and create your own line endings. > When done, delete the original file and rename

Re: Printing unix Line endings from Windows.

2006-12-05 Thread Ant
John Machin wrote: > Ant wrote: ... > > filehandle.write("xxx \n") > > filehandle.write("xxx \x0a") > > > > and all of these give me a nice windows-style crlf! > > > > Surely there must be a way to do this ... > > and there is: op

Re: Working with unsigned/signed types

2006-12-20 Thread Ant
On Dec 20, 6:25 am, <[EMAIL PROTECTED]> wrote: > That seems like it'll do the trick quite well. > > As far as the future generations go, there's no question as to whether it > would > last if it were on my site - there are always changes being made to it and I'm > not expecting it to be very sta

Re: MySQLdb, lots of columns and newb-ness

2006-12-20 Thread Ant
On Dec 20, 5:20 am, Andrew Sackville-West <[EMAIL PROTECTED]> wrote: > > >>> values = ", ".join([escapeAndQuote(f[:-2]) for f in fields]) Obviously this is the appropriate choice since this is a database app. In general the strip() group of string methods do what you want in a safe way - assumin

Re: Anyone persuaded by "merits of Lisp vs Python"?

2007-01-05 Thread Ant
Hi all, On Dec 28 2006, 4:51 pm, "Paddy3118" <[EMAIL PROTECTED]> wrote: > This month there was/is a 1000+ long thread called: > "merits of Lisp vs Python" > In comp.lang.lisp. > > If you followed even parts of the thread, AND previously > used only one of the languages AND (and this is the > cruc

Re: Cross-module imports?

2006-01-23 Thread Ant
You are always likely to have problems of one sort or another if you are using circular references like this. It would be a much better situation redesigning your modules so that they didn't depend on each other. The interpreter is complaining, since it is trying to compile A, hits the line 'impor

Re: Help a C++ escapee!

2007-06-07 Thread Ant
newThreadObject) self.ch=self.ch+1 class CServerThread(threading.Thread): def __init__(self, network): self.network = network def run(self): while (1): self.clientSocket, self.clientAddress = self.network.accept() ... HTH. -- Ant... http:

Re: MySQL - Jython2.2

2007-06-15 Thread Ant
n, use the jdbc driver from www.mysql.com, and you an then use JDBC from within Jython. You'll just need to add the mysql jdbc jar to your classpath. HTH. -- Ant... http://antroy.blogspot.com/ -- http://mail.python.org/mailman/listinfo/python-list

Re: static python classes ?

2007-06-19 Thread Ant
n most OOP languages "static > classes", can you give me a hint ? Hope the above was what you are looking for. -- Ant... http://antroy.blogspot.com/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Can python access windows clipboard

2007-06-21 Thread Ant
ywin32/): import win32clipboard, win32con, random text = "Some text to stick on the clipboard" win32clipboard.OpenClipboard() win32clipboard.SetClipboardData(win32con.CF_TEXT, text) win32clipboard.CloseClipboard() -- Ant... http://antroy.blogspot.com/ -- http://mail.python.org/mailman/listinfo/python-list

Re: About installing new Python version.

2007-04-19 Thread Ant
different directory, and set itself as the default python version. You'll then need to update all your third party extensions to ones compiled against the new version - so if you have a lot of these, it makes sense to wait a while before upgrading. -- Ant. -- http://mail.python.org/mailman/listinfo/python-list

Re: Tutorial creates confusion about slices

2007-04-25 Thread Ant
Hi Antoon, > The best way to remember how slices work is to think of the indices as ... > +---+---+---+---+---+ > | H | e | l | p | A | > +---+---+---+---+---+ > 0 1 2 3 4 5 > -5 -4 -3 -2 -1 > > This is all very well with a simple slice like: > > "HelpA"[2:4]=> "lp

Re: Tutorial creates confusion about slices

2007-04-25 Thread Ant
On Apr 23, 1:38 pm, Antoon Pardon <[EMAIL PROTECTED]> wrote: > The following is part of the explanation on slices in the > tutorial: > > The best way to remember how slices work is to think of the indices as ... > +---+---+---+---+---+ > | H | e | l | p | A | > +---+---+---+---+---+ > 0 1

Re: Tutorial creates confusion about slices

2007-04-25 Thread Ant
On Apr 23, 1:38 pm, Antoon Pardon <[EMAIL PROTECTED]> wrote: > The following is part of the explanation on slices in the > tutorial: > > The best way to remember how slices work is ... > +---+---+---+---+---+ > | H | e | l | p | A | > +---+---+---+---+---+ > 0 1 2 3 4 5 > -5 -4

Re: List objects are un-hashable

2007-04-27 Thread Ant
> for line in inp: > lines +=1 > # a list of words > tempwords = line.split(None) > if keyword.iskeyword(tempwords): > print tempwords You are trying here to ask if a list of words (tempwords) is a keyword. The error is due to the implementation of the iskeyword function wh

Re: List objects are un-hashable

2007-04-27 Thread Ant
> I think it should be: > > if keyword.iskeyword(k): > print k Whoops - yes of course! -- http://mail.python.org/mailman/listinfo/python-list

Re: os.path.join

2007-05-02 Thread Ant
On May 2, 8:03 am, [EMAIL PROTECTED] wrote: > On May 1, 11:10 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> ... > > I think it's a bug, but because it should raise TypeError instead. > > The right usage is os.path.join(*pathparts) ... > Wow. What exactly is that * operator doing? Is it only used in

Re: regexp match string with word1 and not word2

2007-05-02 Thread Ant
On May 2, 9:17 am, Flyzone <[EMAIL PROTECTED]> wrote: > On 30 Apr, 20:00, Steven Bethard <[EMAIL PROTECTED]> wrote: ... > Maybe a right approach will be another if after the first one? Like: >for y in range(0, len(skip_lst) ): > if (re.search(skip_lst[y], line)): >

Re: Searching for a piece of string

2007-05-03 Thread Ant
On May 3, 8:35 am, [EMAIL PROTECTED] wrote: > Hi, > How can i match a part of string and branch to some part of code. > Ex If there is a string like "Timeout" and i want to search only > whether the word "Time" is present in it(which is valid in this > case).so if i have "CastinTime",still this

Re: How to check if a string is empty in python?

2007-05-03 Thread Ant
tring exceptions are depreciated and shouldn't be used. > > >http://docs.python.org/api/node16.html > > They're actually deprecated, not depreciated. In Steven's defence, string exceptions *are* probably worth less, as there's no longer such a demand for them. -- Ant... -- http://mail.python.org/mailman/listinfo/python-list

Re: My Python annoyances

2007-05-04 Thread Ant
On May 4, 3:17 pm, Ben Collver <[EMAIL PROTECTED]> wrote: > Chris Mellon wrote: ... > > Code like this is working directly against Python philosophy. You > > probably got told this on #python, too. There's hardly any > > circumstance where you should need to validate the exact class of an > > objec

Re: N00b question on Py modules

2007-05-09 Thread Ant
On May 9, 2:47 pm, Sion Arrowsmith <[EMAIL PROTECTED]> wrote: ... > How so? Python style gurus discourage use of global variables. So > does all the C++ (and to a lesser extent C) advice I've ever > encountered. And Java outright forbids the concept. Class variables (public static), are the equiva

Re: preferred windows text editor?

2007-05-10 Thread Ant
On May 9, 11:21 pm, BartlebyScrivener <[EMAIL PROTECTED]> wrote: ... > I too vote for VIM. I use it on both Windows XP and Debian Etch. I > can't find anything it doesn't do. I also use Vim (well, GVim). The only thing I find missing is an integrated console for running code snippets/entire scrip

Re: elegant python style for loops

2007-05-10 Thread Ant
27;for i in range...' solution above, and works in cases where zipping the lists may not be appropriate: for i, item in enumerate(mylist): print "%s) My item: %s; My other item: %s" % (i, item, my_non_iterable_object.thing_at(i)) -- Ant. -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie (but improving) - Passing a function name with parameters as a parameter

2007-05-10 Thread Ant
myrecs = ... > def test1(): lookup(myrecs, ['one', 'nomatch']) def test2(): lookup(myrecs, ['one', 'two']) > timeloop(test1, 10) Using timeit: t = timeit.Timer("lookup(myrecs, ['one', 'nomatch'])", "from __

Re: preferred windows text editor?

2007-05-10 Thread Ant
On May 10, 9:59 am, Charles Sanders <[EMAIL PROTECTED]> wrote: > Ant wrote: > > > What method of executing code snippets in a Python shell do other Vim > > users use? Other than just copy/paste? > > Not vim, but good old vi so should work in vim > > 1. Mark th

Re: removing spaces between 2 names

2007-05-15 Thread Ant
27; ... > The methods in the string module are deprecated. Skip the import and > use a string's built in replace() method instead: This is true, but actually Steven *is* using the string's built in replace method - the import isn't used in the code! Obviously the import was

Re: Trying to choose between python and java

2007-05-15 Thread Ant
refer programming in Python when I can (and am even getting quite a lot of Python work at the moment via Jython :-) ) -- Ant... http://antroy.blogspot.com/ -- http://mail.python.org/mailman/listinfo/python-list

HappyDoc, Jython and docstrings

2007-05-15 Thread Ant
does anyone have any solutions? Other programs that do a similar job? Patches for HappyDoc? Cheers, -- Ant... http://antroy.blogspot.com/ -- http://mail.python.org/mailman/listinfo/python-list

Re: HappyDoc, Jython and docstrings

2007-05-15 Thread Ant
On May 15, 12:07 pm, Ant <[EMAIL PROTECTED]> wrote: > Hi All, > > I'm looking to provide online python documentation for several jython > modules: does anyone know if there are tools to create documentation > from docstrings that work in Jython? Jython doesn't provi

Re: Trying to choose between python and java

2007-05-15 Thread Ant
On May 15, 9:17 am, Ant <[EMAIL PROTECTED]> wrote: ... > I can't remember what it is I use - I haven't got access to my server > at the moment... But look in the cheese shop - I'm fairly sure it was > from there. I'll post details if I remember. Alternatively

Re: iteration doesn't seem to work ??

2007-05-16 Thread Ant
ing list comprehension.: 1 > v = ['123', '345', '', '0.3'] 2 > v = [x if x else '3' for x in v] 3 > v 3 = ['123', '345', '3', '0.3'] Note that this replaces the list, so won't be appropriate for modifying a list passed in from elsewhere. -- Ant... http://antroy.blogspot.com/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie Question: Getting a list of files

2007-05-16 Thread Ant
On May 16, 3:07 pm, Gerard Flanagan <[EMAIL PROTECTED]> wrote: ... > import os > > def iter_dirs(root, dirs=False): ... Rather than rolling your own directory walker: The same iterator using os.walk: def iter_dirs(root, dirs=False): for root, directories, files in os.walk(root): if d

Re: Translating some Java to Python

2007-05-21 Thread Ant
ed with the class - for conceptual reasons rather than practical ones, and are rarely used as far as I can tell. I've certainly never bothered with them. In the case of your statAdd above, self is never used in the method body, and so this is a clear indication that a module level fun

Re: Where do they tech Python officialy ?

2007-08-01 Thread Ant
her Comp Sci graduate just after a wage), and secondly that I have experience in good development practice (the open source projects I worked on had better infrastructure in place than two of the three companies I've worked for since!) -- Ant... http://antroy.blogspot.com/ -- http://mail.p

Re: Best programs written completly in Python

2007-08-06 Thread Ant
On Aug 5, 12:31 pm, Campbell Barton <[EMAIL PROTECTED]> wrote: ... > * ubuntu have some of their install tools in python. Gentoo Linux's "Portage" package management tool is written in Python. -- Ant... http://antroy.blogspot.com/ -- http://mail.python.org/mailman/listinfo/python-list

Re: regexp problem in Python

2007-08-07 Thread Ant
ikely to be that you are using m.group(1) with your match object instead of m.group(0) - the former gets the first group (i.e. everything between the first set of parens - in your case the wmv|3gp expression), whereas the latter will return the entire match. Post your actual code, not just the

Re: Seek the one billionth line in a file containing 3 billion lines.

2007-08-08 Thread Ant
: if count == 10: Or probably even: if count == 9: Since the 1 billionth line will have index 9. Cheers, -- Ant... http://antroy.blogspot.com/ -- http://mail.python.org/mailman/listinfo/python-list

Re: py2exe with python 2.5

2007-08-10 Thread Ant
On Aug 10, 11:47 am, [EMAIL PROTECTED] wrote: > On 10 kol, 11:02, Ant <[EMAIL PROTECTED]> wrote: ... > yes,Python 2.5 is on the path, but how can I remove panda3d from that > path? Hit Win - Break to bring up the System Properties dialog (you can also get here through the Control

Re: Smoother Lines in Turtle Graphics

2007-08-10 Thread Ant
gt; > Diez import turtle Its part of the standard Library! I don't know the answer to the OP's question mind you, I'd played around a little with it a while ago, but nothing more. Python: Batteries and Turtles included! -- Ant... http://antroy.blogspot.com/ -- http://mail.python.org/mailman/listinfo/python-list

Re: py2exe with python 2.5

2007-08-10 Thread Ant
rds, > Vedran Sounds like your path needs setting up properly. Try typing echo %PATH % into your console window to find out if Python2.5 is in the path. If you are using the default setup, then c:\Python25 should be on the path. -- Ant... http://antroy.blogspot.com/ -- http://mail.python.org/mailman/listinfo/python-list

Re: The Future of Python Threading

2007-08-11 Thread Ant
nguage designers made the collections API non-thread safe by default (you have to wrap the standard collections in a synchronised wrapper to make them thread safe). -- Ant... -- http://mail.python.org/mailman/listinfo/python-list

Re: creating and appending to a dictionary of a list of lists

2007-08-15 Thread Ant
lly you would use map to get a new list object. In this case the new list returned by map is just a list of None's (since append returns None - a common idiom for functions that operate by side effect), and so is not used directly. -- Ant... http://antroy.blogspot.com/ -- http://mail.python.org/mailman/listinfo/python-list

Re: buggie in else syntax ?

2007-08-15 Thread Ant
ments (any compund statements in fact such as for loops etc) *must* start on a new line (with indentation as necessary): http://docs.python.org/ref/compound.html -- Ant... http://antroy.blogspot.com/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Python question (PyNoob)

2007-08-20 Thread Ant
urllib2 and cookielib in the standard library should do most of what you want, perhaps with the addition of beautiful soup if you need to scrape the pages for data: http://www.crummy.com/software/BeautifulSoup/ HTH. -- Ant... http://antroy.blogspot.com/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbee Question

2007-08-21 Thread Ant
f Python: def counter(std_rate, over_rate, limit): stops = 0 while True: stops += 1 wage = stops * std_rate + max(0, stops - limit) * (over_rate - std_rate) yield stops, wage truck = counter(0.4, 1.4, 22) for i in range(30): print "Stopped %s times, with ac

Re: The folder a script is executed in

2007-08-21 Thread Ant
try something like: os.path.abspath(os.curdir) -- Ant... http://antroy.blogspot.com/ -- http://mail.python.org/mailman/listinfo/python-list

Re: The folder a script is executed in

2007-08-21 Thread Ant
On Aug 21, 10:29 am, [EMAIL PROTECTED] wrote: > On 21 Aug, 11:27, Ant <[EMAIL PROTECTED]> wrote: > > > > > On Aug 21, 10:10 am, [EMAIL PROTECTED] wrote: > > ... > > > > myLocation = GetMyLocation() > > > print myLocation > > > > >

Re: The folder a script is executed in

2007-08-21 Thread Ant
On Aug 21, 10:47 am, Bjoern Schliessmann wrote: > Ant wrote: ... > | print os.path.split(sys.argv[0])[0] > > $ cd tmp > ~/tmp$ ../test.py > .. > ~/tmp$ > > That's rather not what's intended. I'd try os.path.abspath(__file__) > instead. Fair point.

Re: C# and Python

2007-08-21 Thread Ant
Python, the Python implementation for the .Net platform. -- Ant... http://antroy.blogspot.com/ -- http://mail.python.org/mailman/listinfo/python-list

Re: sys.argv is munging my command line options

2007-08-29 Thread Ant
g >From the command prompt: C:\0>test.py action key=value key=value action key=value key=value -- Ant. -- http://mail.python.org/mailman/listinfo/python-list

Re: How to insert in a string @ a index

2007-09-10 Thread Ant
t_function pairs in a dictionary, and reuse this whole block of code for arbitrary keywords with arbitrary rules. -- Ant... -- http://mail.python.org/mailman/listinfo/python-list

Re: python 2.5 problems

2007-09-10 Thread Ant
oad and reinstall 2.2, uninstall 2.2 and 2.5 via Add/Remove Programs and then reinstall 2.5 again. -- Ant... -- http://mail.python.org/mailman/listinfo/python-list

Re: Is numeric keys of Python's dictionary automatically sorted?

2007-03-07 Thread Ant
On Mar 7, 8:18 pm, "John" <[EMAIL PROTECTED]> wrote: ... > However, I am not sure whether it is always like this. Can anybody confirm > my finding? >From the standard library docs: "Keys and values are listed in an arbitrary order which is non-random, varies across Python implementations, and dep

Re: Is numeric keys of Python's dictionary automatically sorted?

2007-03-08 Thread Ant
On Mar 8, 8:20 am, Steven D'Aprano <[EMAIL PROTECTED]> wrote: ... > And the problem with a dictionary is that some people want to make sense > of its order, just like in this case, and the fifty thousand previous > times people have asked this newsgroup how they can sort a dictionary. ... > What ma

Nice plug for Python

2007-03-26 Thread Ant
Sourceforge's Project of the Month (an IT monitoring system written using Zope and Twisted) is a good advert for Python: http://sourceforge.net/potm/potm-2007-03.php -- http://mail.python.org/mailman/listinfo/python-list

Re: Overlapping matches

2007-04-01 Thread Ant
On Apr 1, 9:38 pm, Rehceb Rotkiv <[EMAIL PROTECTED]> wrote: > In the re documentation, it says that the matching functions return "non- > overlapping" matches only, but I also need overlapping ones. Does anyone > know how this can be done? Something like the following: import re s = "" p

Re: redirecting stdout to a file as well as screen

2007-04-12 Thread Ant
On Apr 12, 8:14 am, "SamG" <[EMAIL PROTECTED]> wrote: > How could i make, from inside the program, to have the stdout and > stderr to be printed both to a file as well the terminal(as usual). One way would be to create a custom class which has the same methods as the file type, and held a list of

Win32com, and Excel issues.

2007-04-18 Thread Ant
Hi all, I'm doing some Excel automation work for a friend, and am developing on a machine running Office 2000. My friends machine is running Excel 2003. The code I've written works like a charm on my machine (in fact all three of my machines), but falls over early on on Excel 2003. The code snipp

Re: Win32com, and Excel issues.

2007-04-18 Thread Ant
ttp://mathieu.fenniak.net/plotting-in-excel-through-pythoncom/ Thanks, I've already seen those pages (in fact I have the book) but no luck. In fact it's worse - I've tested it out on a different machine running Excel 2003, and it works fine :-( Which means that there's another

Re: An Editor that Skips to the End of a Def

2007-09-21 Thread Ant
On Sep 21, 4:47 am, "W. Watson" <[EMAIL PROTECTED]> wrote: > How about in the case of MS Win? Both emacs and vim have GUI versions that run on Windows. -- Ant... -- http://mail.python.org/mailman/listinfo/python-list

<    1   2   3   4   >