Re: Specifing arguments type for a function

2006-07-04 Thread Magnus Lycka
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? You can state that in your documentation. You're very likely to get a reasonable runtime error from this when y

Re: inline metaclasses

2006-07-04 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, K.S.Sreeram wrote: > Marc 'BlackJack' Rintsch wrote: >> But why use a metaclass? If the meta class is only applied to *one* >> class, can't you do at class level whatever the metaclass is doing!? > > The very fact that you can put a loop inside __metaclass__ may be reason

Re: classes and interfaces

2006-07-04 Thread Diez B. Roggisch
Rene Pijlman schrieb: > Bruno Desthuilliers: >> Java interfaces are a workaround > > Troll alert. No idea how you come to that conclusion - but he is actually right with that. Diez -- http://mail.python.org/mailman/listinfo/python-list

Re: converting file formats to txt

2006-07-04 Thread Fredrik Lundh
Marc 'BlackJack' Rintsch wrote: > What do you mean by 'fileformats'? A script that automagically converts > *anything* to text? What about pictures? that's a one-and-a-half-liner: import Image, sys; print list(Image.open(sys.argv[1]).getdata()) -- http://mail.python.org/mailman/list

Re: a question about "return"

2006-07-04 Thread Fredrik Lundh
"yaru22" wrote: > In one of the examples in the book I'm reading, it says: > > def __init__(self): >... >... >... >return > > It has nothing after "return". I expected it to have some number like 0 or 1. > > What does it mean to have nothing after return? "return" is the same thi

Re: languages with full unicode support

2006-07-04 Thread Joachim Durchholz
Oliver Bandel schrieb: > Matthias Blume wrote: > >> Tin Gherdanarra <[EMAIL PROTECTED]> writes: >> >> >>> Oliver Bandel wrote: >>> こんいちわ Xah-Lee san ;-) >>> >>> Uhm, I'd guess that Xah is Chinese. Be careful >>> with such things in real life; Koreans might >>> beat you up for this. Stay alive

Re: Dictionary .keys() and .values() should return a set [with Python 3000 in mind]

2006-07-04 Thread Antoon Pardon
On 2006-07-01, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > There's a few good reasons. > 1 - golden handcuffs. Breaking old code is bad 90% of the time > 2 - creating a set MAY be slower. > > Python's sets seem to imply to that they will always be a hash map. in > this case, some creative hash

Re: Threads and time.strptime()

2006-07-04 Thread Maximilian Michel
The parsing thread reads also the file from the disk. placid wrote: > Maximilian Michel wrote: > > Hi all, > > > > I have an interesting problem: > > I have written code, that reads a logfile and parses it for date string > > (Thu Jun 29 14:01:23 2006). > > Standalone everthing works fine, all is

Sudoko solver

2006-07-04 Thread Rony Steelandt
Hi all, I wonder if somebody had a Sudoko solver written in Python ? Rony -- http://mail.python.org/mailman/listinfo/python-list

Re: Out of the box database support

2006-07-04 Thread Alex Biddle
> > Do you really want "smarmy" here? I don't think it works. Don't you > > mean "flip" or "smart-alecky" or "facetious"? > > Hmm. I think the word we're looking for here is "snarky". ;-) > > Although, I confess to ignorance on what a "snark" is or whether > it is particularly known for brief sel

Re: What is Expressiveness in a Computer Language

2006-07-04 Thread Joachim Durchholz
Andreas Rossberg schrieb: > AFAICT, ADT describes a type whose values can only be accessed by a > certain fixed set of operations. Classes qualify for that, as long as > they provide proper encapsulation. The first sentence is true if you associate a semantics (i.e. axioms) with the operations.

Re: Sudoko solver

2006-07-04 Thread Fredrik Lundh
Rony Steelandt wrote: > I wonder if somebody had a Sudoko solver written in Python ? http://www.google.com/search?q=python+soduko returns some 15000 hits, including this little gem: http://norvig.com/sudoku.html -- http://mail.python.org/mailman/listinfo/python-list

finding items that occur before or after an item in lists

2006-07-04 Thread Simon Forman
I've got a function that I'd like to improve. It takes a list of lists and a "target" element, and it returns the set of the items in the lists that appear either before or after the target item. (Actually, it's a generator, and I use the set class outside of it to collect the unique items, but y

Re: Threads and time.strptime()

2006-07-04 Thread Maximilian Michel
Thank you so much! (2) was the reason! Without threads, locale.getlocale() returns (None, None), while calling it in this thread gives back ('de_DE', 'iso-8859-15'). I'm still curious, why this occurs, but anyway it's fixable with setlocale(LC_ALL, 'C'); so normally Python doesn't set locales accor

Re: Controlling Windows Media Player from Python

2006-07-04 Thread Alex Biddle
> > Take a look at pywinauto, I attended the today talk at EP2006 and seemed > really cool. http://pywinauto.pbwiki.com > Cool, that looks really interesting. ...theres a problem I could solve with that -- http://mail.python.org/mailman/listinfo/python-list

Re: Sudoko solver

2006-07-04 Thread Ángel Gutiérrez Rodríguez
I have one myself (~400 records). it uses the simplest rules, and then trial and error, but it works so far. -- Ángel Gutiérrez Rodríguez - [EMAIL PROTECTED] Instituto de Ciencia de los Materiales de Madrid - CSIC SpLine - European Syncrothorn Radiation Facility - Grenoble - France Postal adress

Re: Sudoko solver

2006-07-04 Thread Simon Forman
Rony Steelandt wrote: > Hi all, > > I wonder if somebody had a Sudoko solver written in Python ? > > Rony Dude, there's like a million of them. Try "Sudoko solver Python" in google. I wrote one myself based on Knuth's Dancing Links algorithm and using Tkinter for the gui. I'll send it to you or

Re: Out of the box database support

2006-07-04 Thread Fredrik Lundh
Alex Biddle wrote: > The message in this case was that I /couldn't/ install anything by > myself as it is on a /shared/ server that's why I wanted to know > whether there was anything out of the box I could use. but you did search the library reference TOC and/or the index for "database" before

Re: Out of the box database support

2006-07-04 Thread Alex Biddle
Yes, I searched but couldn't find anything. Maybe I wasn't searching for the right things / in the right places. I admit I'm more used to forums than mailing lists, but I always make some effort to search. On 7/4/06, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > but you did search the library refere

Re: Out of the box database support

2006-07-04 Thread Terry Hancock
Alex Martelli wrote: > Terry Hancock <[EMAIL PROTECTED]> wrote: ... > > Although, I confess to ignorance on what a "snark" is or whether > > http://www.gutenberg.org/etext/13 "The Hunting of the Snark" by Lewis Caroll Of course! I've heard of it, but never read it. Thanks, Alex. :-) Not sure

Re: inline metaclasses

2006-07-04 Thread K.S.Sreeram
Marc 'BlackJack' Rintsch wrote: > K.S.Sreeram wrote: >> The very fact that you can put a loop inside __metaclass__ may be reason >> enough for a one-off metaclass. > > Ah, it's not the loop but the access to the `dict`! You can write loops > at class level too but I haven't found a way to access

Re: "Next Generation Artificial Intelligence, Artificial Mind - Part One - Basic Architecture and Cognitive Structure"

2006-07-04 Thread Terry Hancock
tommak wrote: > This book, "Next Generation Artificial Intelligence, Artificial Mind > - Part One - Basic Architecture and Cognitive Structure" introduces a > basic artificial mind architecture and computational model for > cognitive processing. Based on the architecture and the > computationa

Re: Sudoko solver

2006-07-04 Thread Rony Steelandt
"Sybren Stuvel" <[EMAIL PROTECTED]> a écrit dans le message de news: [EMAIL PROTECTED] > Rony Steelandt enlightened us with: >> I wonder if somebody had a Sudoko solver written in Python ? > > Check out http://www.stuvel.eu/sodoku - it is a Sudoku game with the > ability to solve & create new puz

Re: Time out question

2006-07-04 Thread Nick Craig-Wood
Grant Edwards <[EMAIL PROTECTED]> wrote: > On 2006-07-03, Nick Craig-Wood <[EMAIL PROTECTED]> wrote: > > Alex Martelli <[EMAIL PROTECTED]> wrote: > >> DarkBlue <[EMAIL PROTECTED]> wrote: > >> > try for 10 seconds > >> >if database.connected : > >> > do your remote thing > >> > except ra

Re: Sudoko solver

2006-07-04 Thread Rony Steelandt
"Sybren Stuvel" <[EMAIL PROTECTED]> a écrit dans le message de news: [EMAIL PROTECTED] > Rony Steelandt enlightened us with: >> I wonder if somebody had a Sudoko solver written in Python ? > > Check out http://www.stuvel.eu/sodoku - it is a Sudoku game with the > ability to solve & create new puz

Re: a question about "return"

2006-07-04 Thread Petr Prikryl
"yaru22" wrote in message news:[EMAIL PROTECTED] > In one of the examples in the book I'm reading, it says: > > def __init__(self): > ... > return > > It has nothing after "return". I expected it to have some number like 0 > or 1. What does it mean to have nothing after return? Yes, it ha

Re: [noob question] References and copying

2006-07-04 Thread Petr Prikryl
"zefciu" wrote in message news:[EMAIL PROTECTED] > Where can I find a good explanation when does an interpreter copy the > value, and when does it create the reference. I thought I understand > it, but I have just typed in following commands: > > >>> a=[[1,2],[3,4]] > >>> b=a[1] > >>> b=[5,6] > >>

Re: starting and stopping a program from inside a python script

2006-07-04 Thread Amit Khemka
You can store the pid of the process when started and later use it to kill it. cheers, On 3 Jul 2006 15:28:19 -0700, dfaber <[EMAIL PROTECTED]> wrote: > Aloha! > I want to terminate a process/program from within a python script. > > For example, > if I have a program say foo.sh that starts runni

Re: For a fast implementation of Python

2006-07-04 Thread Terry Hancock
. wrote: > What is the fast way for a fast implementation of Python? > > -- JavaScript implementation of Python > http://groups.google.it/group/JSython/ Follow the PyPy link. The other replies were about increasing execution speed, not ease of implementation. Implement the "RPython" part in

Re: sqlite3 in Python 2.5b1: my out-of-the-box experience

2006-07-04 Thread Georg Brandl
John Machin wrote: > Apologies in advance if this is a bit bloggy, but I'd like to get > comments on whether I've lost the plot (or, more likely, failed to > acquire it) before I start reporting bugs etc. Please forward to Gerhard Haering if you still think these are bugs. Georg -- http://mai

Re: style question

2006-07-04 Thread Terry Hancock
Hari Sekhon wrote: > Is it better to do: > message = """This is line1. This is line2 This is line3\n""" > > or > > message = "This is line1.\n message = message + "This is line2\n" > message = message + "This is line3\n" > > Since the first method does not follow python's clean and easy > lo

Illegal instruction or undefined symbol from import

2006-07-04 Thread Mathias Waack
Hi, I've embedded python into a legacy application. It works - most of the time. In some special situations the app crashes executing the "import random". There are two different situations: 1. the sources compiled with gcc 4.1.2 crash with illegal instruction error: (running my application)

Re: languages with full unicode support

2006-07-04 Thread Pascal Bourguignon
Joachim Durchholz <[EMAIL PROTECTED]> writes: > Oliver Bandel schrieb: >> Matthias Blume wrote: >> >>> Tin Gherdanarra <[EMAIL PROTECTED]> writes: >>> >>> Oliver Bandel wrote: > こんいちわ Xah-Lee san ;-) Uhm, I'd guess that Xah is Chinese. Be careful with such things in r

gathering some opinions

2006-07-04 Thread eight02645999
hi i am working on cgi and wish to gather some input on correct/often used methods of what i am going to do. I need to let the user choose (in the form of check boxes) whether they need the data to be emailed to them periodically. So if they click the check box on "activate", then email system will

fonction in python

2006-07-04 Thread aliassaf
Hello, If we write = x^2 and if I give to the program the values of x, it will going to calculate the values of y, and also for x. But it is possible ? that is if I give to the program the values of X and Y, it will indicate to me the relation between the two variables, in the other hand

change the size of front

2006-07-04 Thread aliassaf
hi, I want to change the size of the front in a legend, i wrote this small program and it got to me this message error!!! from pylab import * plot([1,2,3],'r') legend('this',prop = FontProperties('smaller') ) show() NameError: name 'FontProperties' is not defined thanks -- View this message

Re: xpath question

2006-07-04 Thread Stefan Behnel
[EMAIL PROTECTED] wrote: > bruce wrote: >> is there anyone with XPath expertise here? i'm trying to figure out if >> there's a way to use regex expressions with an xpath query? i've seen >> references to the ability to use regex and xpath/xml, but i'm not sure how >> to do it... >> >> i have a situ

Re: Sudoko solver

2006-07-04 Thread Rony Steelandt
"Sybren Stuvel" <[EMAIL PROTECTED]> a écrit dans le message de news: [EMAIL PROTECTED] > Rony Steelandt enlightened us with: >> it looks like both zip files are corrupted (for windows platform)? > > Can you tell me more? So far I can only tell you that they work just > fine for me, and 'unzip -t

Re: Sudoko solver

2006-07-04 Thread Fredrik Lundh
Rony Steelandt wrote: > Yes, this is on windows using winzip > It says the zip file is not a valid zipfile make sure you save it to disk before opening it. -- http://mail.python.org/mailman/listinfo/python-list

Re: fonction in python

2006-07-04 Thread Georg Brandl
aliassaf wrote: > Hello, > > If we write = x^2 and if I give to the program the values of x, it will > going to calculate the values of y, and also for x. > > But it is possible ? that is if I give to the program the values of X and Y, > it will indicate to me the relation between the two

sys.exit call from pythonw.exe gives error

2006-07-04 Thread Omer KORKMAZ
  I wrote a python GUI with tkInter and installed it on a windows machinewith the .pyw extension, so it will be executed from pythonw.exe insteadof python.exe, since I didn't want the console window to appear.My application exits with a call to sys.exit. However, when this call isexecuted

sys.exit call from pythonw.exe gives error

2006-07-04 Thread Omer KORKMAZ
  I wrote a python GUI with tkInter and installed it on a windows machinewith the .pyw extension, so it will be executed from pythonw.exe insteadof python.exe, since I didn't want the console window to appear.My application exits with a call to sys.exit. However, when this call isexecuted

sys.exit call from pythonw.exe gives error

2006-07-04 Thread Omer KORKMAZ
I wrote a python GUI with tkInter and installed it on a windows machinewith the .pyw extension, so it will be executed from pythonw.exe insteadof python.exe, since I didn't want the console window to appear.My application exits with a call to sys.exit. However, when this call isexecuted under

Re: change the size of front

2006-07-04 Thread Dennis Benzinger
aliassaf wrote: > hi, > I want to change the size of the front in a legend, i wrote this small > program and it got to me this message error!!! > > from pylab import * > plot([1,2,3],'r') > legend('this',prop = FontProperties('smaller') ) Try legend('this',prop = matplotlib.font_manager.FontPro

Howto get the argument defaults of a function using an AST-object?

2006-07-04 Thread stefan
Hi, for a school project I'm trying to analyze some python modules. I just struggeld over a little detail I cannot solve: shortened example of walking trough an AST with my own visitor: class MyVisitor: def visitFunction(self, t): # Here I do not know know how to associate the defaul

Re: Howto get the argument defaults of a function using an AST-object?

2006-07-04 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > I can only get a list with the arguments or the defaults. The following > examples would return the same: > > def foo(x, y=True) > def foo(x=True, y) the latter is a syntax error. > Anyone an idea? the defaults array contains the defaults for the len(defaults) last ar

Re: inline metaclasses

2006-07-04 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, K.S.Sreeram wrote: >> BTW, if that's what gangesmaster is after then it seem to work already. >> Put ``(object)`` after ``X`` and return something, say 'a' and 'b', in the >> getters and the example prints 'a' and 'b'. > > btw, the example seems to work even with old-styl

Re: Py2exe make wxPython window looks bad

2006-07-04 Thread Jonathan Harris
Ray wrote: > http://wiki.wxpython.org/index.cgi/FAQ#head-4cc058aed6216dd200d55a6e4c077ccbe82bd142 Here's a trick that embeds the manifest into the executable (which is a little cleaner) and adds meta info. 1. Add this to the top of your setup.py. Supply your application's name, version number

Oracle DBI Module? Recommendations

2006-07-04 Thread cdecarlo
Hello, I'm planning on starting some database work on an Oracle 9i database, any suggestions on which module I should use. >From the python.org website I see that the options are: - DCOracle2 - cx_Oracle - mxODBC Any help would be appreciated but please, support your answers somehow. Thanks

Re: Sudoko solver

2006-07-04 Thread Jon Ribbens
In article <[EMAIL PROTECTED]>, Rony Steelandt wrote: > Yes, this is on windows using winzip > It says the zip file is not a valid zipfile Works fine for me on Windows. Try deleting the file you downloaded, clearing your browser cache, and trying again. On the other hand, when you run it it immed

Re: Howto get the argument defaults of a function using an AST-object?

2006-07-04 Thread stefan
Fredrik Lundh schrieb: > > > def foo(x, y=True) > > def foo(x=True, y) > > the latter is a syntax error. > ... > > the defaults array contains the defaults for the len(defaults) last arguments. And again the own stupidity: I didn't check all my testcases for syntax errors. Thanks a lot,

weird error messages on application exit

2006-07-04 Thread ianaré
Running FC5 with Gnome (rather minimal install), using latest wxPython version installed from wxPython.org RPMs since I needed unicode and FC5 only has ansi available in the package manager. Anyway the errors occur every time i close out of my wxPython application, and sometimes... maybe every 10 -

Nested scopes, and augmented assignment

2006-07-04 Thread Tim N. van der Leeuw
Hi, The following might be documented somewhere, but it hit me unexpectedly and I couldn't exactly find this in the manual either. Problem is, that I cannot use augmented assignment operators in a nested scope, on variables from the outer scope: PythonWin 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC

Jythonc Problem

2006-07-04 Thread Ian Vincent
I cannot find a Jython newsgroup, so apologies in advance if this question has been posted to the wrong group. Just written my first Jython program (previously written Python ones) and it is working fine in 'interpreted mode'. I now want to compile it into Java classes but I get the following e

Re: Nested scopes, and augmented assignment

2006-07-04 Thread Diez B. Roggisch
Tim N. van der Leeuw wrote: > Hi, > > The following might be documented somewhere, but it hit me unexpectedly > and I couldn't exactly find this in the manual either. > > Problem is, that I cannot use augmented assignment operators in a > nested scope, on variables from the outer scope: > Is

regex module, or don't work as expected

2006-07-04 Thread Fabian Holler
Howdy, i have the following regex "iface lo[\w\t\n\s]+(?=(iface)|$)" If "iface" don't follow after the regex "iface lo[\w\t\n\s]" the rest of the text should be selected. But ?=(iface) is ignored, it is always the whole texte selected. What is wrong? many thanks greetings Fabian -- http://m

Re: converting file formats to txt

2006-07-04 Thread Gaurav Agarwal
Hi, I wanted a script that can convert any file format (RTF/DOC/HTML/PDF/PS etc) to text format. Regards, Gaurav Agarwal Fredrik Lundh wrote: > Marc 'BlackJack' Rintsch wrote: > > > What do you mean by 'fileformats'? A script that automagically converts > > *anything* to text? What about pictu

Re: Odd behavior with staticmethods

2006-07-04 Thread Bruno Desthuilliers
[EMAIL PROTECTED] wrote: please stop top-posting, it's getting very annoying > ya know, I've searched for these "new classes" at least five times. Then go and buy yourself a pair of glasses. It's one of the entrie in the "documentation" menu of python.org. -- bruno desthuilliers python -c "pri

Re: languages with full unicode support

2006-07-04 Thread Mumia W.
Pascal Bourguignon wrote: > [...] > (coerce (lschar :name "LATIN") 'string) > --> "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz > ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóô > [...] In what programming language/interpreter is this code? -- http://mail.python.org/mailman/li

Matplotlib eps export

2006-07-04 Thread Martin Manns
Hi, When I use matplotlib for a scatter plot with both dots and connecting lines, the exported eps file is huge, if the distances between many points are small. I think of this as a bug, since no preview tiff is included in the generated eps and a variety of text processing applications (including

List Manipulation

2006-07-04 Thread Roman
I would appreciate it if somebody could tell me where I went wrong in the following snipet: When I run I get no result cnt = 0 p=[] reader = csv.reader(file("f:\webserver\inp.txt"), dialect="excel", quotechar="'", delimiter='\t') for line in reader: if cnt > 6:

Re: weird error messages on application exit

2006-07-04 Thread Frank Millman
ianaré wrote: > Running FC5 with Gnome (rather minimal install), using latest wxPython > version installed from wxPython.org RPMs since I needed unicode and FC5 > only has ansi available in the package manager. Anyway the errors occur > every time i close out of my wxPython application, and someti

Re: List Manipulation

2006-07-04 Thread Mike Kent
Roman wrote: > I would appreciate it if somebody could tell me where I went wrong in > the following snipet: > > When I run I get no result > > cnt = 0 > p=[] > reader = csv.reader(file("f:\webserver\inp.txt"), dialect="excel", > quotechar="'", delimiter='\t') > for line in

Re: List Manipulation

2006-07-04 Thread Iain King
Roman wrote: > I would appreciate it if somebody could tell me where I went wrong in > the following snipet: > > When I run I get no result > > cnt = 0 > p=[] > reader = csv.reader(file("f:\webserver\inp.txt"), dialect="excel", > quotechar="'", delimiter='\t') > for line i

built in zip function speed

2006-07-04 Thread [EMAIL PROTECTED]
I hope I am not being too ignorant :p but here goes... my boss has written a bit of python code and asked me to speed it up for him... I've reduced the run time from around 20 minutes to 13 (not bad I think ;) to speed it up further I asked him to replace a loop like this:- index = 0 for element

Re: List Manipulation

2006-07-04 Thread Laszlo Nagy
Roman írta: > I would appreciate it if somebody could tell me where I went wrong in > the following snipet: > > When I run I get no result > > cnt = 0 > p=[] > reader = csv.reader(file("f:\webserver\inp.txt"), dialect="excel", > quotechar="'", delimiter='\t') > for line in

Re: List Manipulation

2006-07-04 Thread Steven D'Aprano
On Tue, 04 Jul 2006 07:01:55 -0700, Roman wrote: > I would appreciate it if somebody could tell me where I went wrong in > the following snipet: > > When I run I get no result What do you mean? Does it print None? > cnt = 0 > p=[] > reader = csv.reader(file("f:\webserver\inp.txt"), dialect="exc

Re: converting file formats to txt

2006-07-04 Thread Grant Edwards
On 2006-07-04, Gaurav Agarwal <[EMAIL PROTECTED]> wrote: > I wanted a script that can convert any file format (RTF/DOC/HTML/PDF/PS > etc) to text format. And I want to win the lottery. Without having to buy tickets. -- Grant Edwards grante Yow! You can't hurt

Re: converting file formats to txt

2006-07-04 Thread Steven D'Aprano
On Tue, 04 Jul 2006 06:32:13 -0700, Gaurav Agarwal wrote: > Hi, > > I wanted a script that can convert any file format (RTF/DOC/HTML/PDF/PS > etc) to text format. RTF, HTML and PS are already text format. DOC is a secret, closed proprietary format. It will be a lot of work reverse-engineering i

Re: built in zip function speed

2006-07-04 Thread Rune Strand
itertools.izip is usually faster than zip. You can try that. -- http://mail.python.org/mailman/listinfo/python-list

Re: handling unicode data

2006-07-04 Thread Filipe
Martin v. Löwis wrote: > Filipe wrote: > > output --- > > u'Fran\xd8a' > > FranØa > > > > > > What do you think? Might it be Pymssql doing something wrong? > > I think the data in your database is

Re: fonction in python

2006-07-04 Thread Steven D'Aprano
On Tue, 04 Jul 2006 03:06:37 -0700, aliassaf wrote: > > Hello, > > If we write = x^2 and if I give to the program the values of x, it will > going to calculate the values of y, and also for x. > > But it is possible ? that is if I give to the program the values of X and Y, > it will indi

Re: List Manipulation

2006-07-04 Thread Roman
Thanks for your help My intention is to create matrix based on parsed csv file. So, I would like to have a list of columns (which are also lists). I have made the following changes and it still doesn't work. cnt = 0 p=[[], [], [], [], [], [], [], [], [], [], []] reader = csv.reader(file("f:\we

Re: List Manipulation

2006-07-04 Thread Sibylle Koczian
Roman schrieb: > I would appreciate it if somebody could tell me where I went wrong in > the following snipet: > > When I run I get no result > > cnt = 0 > p=[] > reader = csv.reader(file("f:\webserver\inp.txt"), dialect="excel", > quotechar="'", delimiter='\t') > for lin

Re: Can anyone please analyse this program for me (write a pseudocode for it).

2006-07-04 Thread Steven D'Aprano
On Mon, 03 Jul 2006 06:20:36 -0700, Vusi wrote: > /* $Id: dotquad.c 3529 2005-10-01 10:15:22Z dyoung $ */ > /* > * Copyright (c) 2003, 2004 David Young. All rights reserved. > * > * This code was written by David Young. [snip code] Am I the only one who found it hilarious that this piece of

Re: regex module, or don't work as expected

2006-07-04 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Fabian Holler wrote: > Howdy, > > > i have the following regex "iface lo[\w\t\n\s]+(?=(iface)|$)" > > If "iface" don't follow after the regex "iface lo[\w\t\n\s]" the rest of > the text should be selected. > But ?=(iface) is ignored, it is always the whole texte selected

Re: built in zip function speed

2006-07-04 Thread [EMAIL PROTECTED]
Rune Strand wrote: > itertools.izip is usually faster than zip. You can try that. Thanks very much timing for itertools.izip for av, bv, cv, dv in itertools.izip(a, b, c, d): avbv = (av-bv) * (av - bv) diff = cv - dv e.append(diff - avbv) on a 4 million element aray: slice: 8.06299

Re: List Manipulation

2006-07-04 Thread Mike Kent
Roman wrote: > Thanks for your help > > My intention is to create matrix based on parsed csv file. So, I would > like to have a list of columns (which are also lists). > > I have made the following changes and it still doesn't work. > > > cnt = 0 > p=[[], [], [], [], [], [], [], [], [], [], []] >

RE: ascii character - removing chars from string

2006-07-04 Thread bruce
simon... the issue that i'm seeing is not a result of simply using the 'string.replace' function. it appears that there's something else going on in the text although i can see the nbsp in the file, the file is manipulated by a number of other functions prior to me writing the information out

Re: For a fast implementation of Python

2006-07-04 Thread .
Hi Terry. I see: http://codespeak.net/pypy/dist/pypy/doc/news.html "...by translating RPython to Javascript..." It isn't an implementation. -- JavaScript implementation of Python http://groups.google.it/group/JSython/ Terry Hancock ha scritto: > . wrote: > > > What is the fast way for a fast

Re: List Manipulation

2006-07-04 Thread Diez B. Roggisch
> p[j] does not give you a reference to an element inside p. It gives > you a new sublist containing one element from p. You then append a > column to that sublist. Then, since you do nothing more with that > sublist, YOU THROW IT AWAY. Not correct. p = [[]] p[0].append(1) print p yields [[1

Re: regex module, or don't work as expected

2006-07-04 Thread Fabian Holler
Hello Marc, thank you for your answer. Marc 'BlackJack' Rintsch wrote: > In <[EMAIL PROTECTED]>, Fabian Holler wrote: >> i have the following regex "iface lo[\w\t\n\s]+(?=(iface)|$)" >> >> If "iface" don't follow after the regex "iface lo[\w\t\n\s]" the rest of >> the text should be selected. >

Re: built in zip function speed

2006-07-04 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > ## just for a laugh my own zip function > ## the joke is it runs faster than built in zip ?? since it doesn't do the same thing, it's not a very good joke. > def myzip(*args): > index = 0 > for elem in args[0]: > zipper = [] > for arg in args: >

Re: built in zip function speed

2006-07-04 Thread Steven D'Aprano
On Tue, 04 Jul 2006 07:18:29 -0700, [EMAIL PROTECTED] wrote: > I hope I am not being too ignorant :p but here goes... my boss has > written a bit of python code and asked me to speed it up for him... > I've reduced the run time from around 20 minutes to 13 (not bad I think > ;) to speed it up furt

Re: built in zip function speed

2006-07-04 Thread Rune Strand
> so fastest overall you may experience speed-ups by using from itertools import izip and just use izip() instead to avoid the module namespace lookup. The same applies for the list.append() methods. If you're appending some million times a_list = [] a_list_append = a_list.append a_list_append

Re: List Manipulation

2006-07-04 Thread Roman
Nothing got printed. Could you tell me what would be pythonic version of what I am trying to do? Diez B. Roggisch wrote: > > p[j] does not give you a reference to an element inside p. It gives > > you a new sublist containing one element from p. You then append a > > column to that sublist. T

Re: built in zip function speed

2006-07-04 Thread [EMAIL PROTECTED]
Steven D'Aprano wrote: > On Tue, 04 Jul 2006 07:18:29 -0700, [EMAIL PROTECTED] wrote: > > > I hope I am not being too ignorant :p but here goes... my boss has > > written a bit of python code and asked me to speed it up for him... > > I've reduced the run time from around 20 minutes to 13 (not bad

Re: regex module, or don't work as expected

2006-07-04 Thread Fredrik Lundh
Fabian Holler wrote: > Yes thats right, but that isn't my problem. > The problem is in the "(?=(iface)|$)" part. no, the problem is that you're thinking "procedural string matching from left to right", but that's not how regular expressions work. > I have i.e. the text: > > "auto lo eth0 > ifa

Re: built in zip function speed

2006-07-04 Thread [EMAIL PROTECTED]
Fredrik Lundh wrote: > [EMAIL PROTECTED] wrote: > > > ## just for a laugh my own zip function > > ## the joke is it runs faster than built in zip ?? > > since it doesn't do the same thing, it's not a very good joke. > > > def myzip(*args): > > index = 0 > > for elem in args[0]: > >

RE: ascii character - removing chars from string

2006-07-04 Thread Steven D'Aprano
On Tue, 04 Jul 2006 08:09:53 -0700, bruce wrote: > simon... > > the issue that i'm seeing is not a result of simply using the > 'string.replace' function. it appears that there's something else going on > in the text > > although i can see the nbsp in the file, the file is manipulated by a n

Re: built in zip function speed

2006-07-04 Thread bearophileHUGS
[EMAIL PROTECTED]: Using Python you can do: # Data: l_a = [1.1, 1.2] l_b = [2.1, 2.2] l_c = [3.1, 3.2] l_d = [5.1, 4.2] from itertools import izip l_e = [(c-d) - (a-b)*(a-b) for a,b,c,d in izip(l_a, l_b, l_c, l_d)] print l_e With psyco + the standard module array you can probably go quite fast,

Re: converting file formats to txt

2006-07-04 Thread Gaurav Agarwal
Thanks Steven, Actually i wanted a do text processing for my office where I can view all files in the system and use the first three to give a summary of the document. Instead of having somebody actually entering the summary. Seems there is no one code that can act as convertor across formats, i'll

Requesting advice on uploading a module

2006-07-04 Thread Anthra Norell
Hi all,      I have invested probably 500 hours in the development of a module which I think could fill a gap, judging by some problems regularly discussed on this forum. The module is finished and I want to contribute it. A kind sould recently suggested I upload it to the Cheese Shop. I

Re: List Manipulation

2006-07-04 Thread Bruno Desthuilliers
Roman wrote: (please dont top-post - corrected) > > Iain King wrote: > >>Roman wrote: >> >>>I would appreciate it if somebody could tell me where I went wrong in >>>the following snipet: >>> (snip) >>What are you trying to do here? p[:0] returns a new list, of all the >>elements in p up to ele

RE: ascii character - removing chars from string

2006-07-04 Thread bruce
update... the error i'm getting... >>>UnicodeEncodeError: 'ascii' codec can't encode character u'\xa0' in position 62: ordinal not in range(128) is there a way i can tell/see what the exact char is at pos(62). i was assuming that it's the hex \xa0. i've done the s.replace('\xa0','') with no luc

Client Server Connection Program

2006-07-04 Thread diffuser78
Hi, I have the following code for a cline and server which I got from a small tutorial on the web. #!/ usr/bin/env python # tms.py (SERVER) import socket import sys s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) host = '' port = int(sys.argv[1]) s.bind((host,port)) s.listen(1) conn, add

RE: ascii character - removing chars from string

2006-07-04 Thread bruce
steven... when you have the >>>u'hello ? world'<< in your interpreter/output, is the 'u' indicating that what you're displaying is unicode? i pretty much tried what you have in the replace.. and i got the same error regarding the unicodedecode error... -Original Message- From: [EMAIL

Code design for a sub-class of built-ins

2006-07-04 Thread Steven D'Aprano
I'm having problems with sub-classes of built-in types. Here is a contrived example of my subclass. It isn't supposed to be practical, useful code, but it illustrates my problem. class MyStr(str): """Just like ordinary strings, except it exhibits special behaviour for one particular value

Re: built in zip function speed

2006-07-04 Thread Peter Otten
[EMAIL PROTECTED] wrote: > I hope I am not being too ignorant :p but here goes... my boss has > written a bit of python code and asked me to speed it up for him... > I've reduced the run time from around 20 minutes to 13 (not bad I think > ;) to speed it up further I asked him to replace a loop li

Re: Client Server Connection Program

2006-07-04 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > #/ usr/bin/env python > # filename: tmc.py (CLIENT) > > import socket > import sys > > s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) > > host = int(sys.argv[1]) > port = int(sys.argv[2]) the port number is an integer, but the host name/ip is obviously not an

  1   2   >