Re: Still the __new__ hell ...

2007-03-18 Thread Arnaud Delobelle
On Mar 17, 11:48 pm, Paulo da Silva <[EMAIL PROTECTED]> wrote: > Arnaud Delobelle escreveu:> On Mar 17, 9:31 pm, Paulo da Silva <[EMAIL > PROTECTED]> wrote: [snip] > Thanks. This works exactly the way you wrote. > Yet I am misunderstanding something. Can't pickle "see" that being > MyDate derive

Re: Finding the insertion point in a list

2007-03-18 Thread Paul Rubin
Steve Holden <[EMAIL PROTECTED]> writes: > >max(i for i,t in enumerate(x) if t <= y) > > Those are actually pretty direct. > > How about a solution (like the bisect one suggested almost as soon as > this thread started) that doesn't iterate over the whole list. Here's a Haskell-inspired one:

Re: Webcams and python

2007-03-18 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Synt4x wrote: > from VideoCapture import Device > cam = Device() > > while 1: > img = cam.getImage() > > Now, by doing this, my processor fires up to 100% load, which > obviously makes my pc useless. > > Is there any way or algorithm to lower the cpu load? Just thro

Re: lock problem

2007-03-18 Thread Gabriel Genellina
En Fri, 16 Mar 2007 19:08:14 -0300, Ritesh Raj Sarraf <[EMAIL PROTECTED]> escribió: >> But you miss the fact that there is only one environment per process. > > Maybe there's a confusion. > The environment variable that I'm setting has noting to do with > ldapsearch. I > use the environment va

Re: cannot start IDLE in WinXP

2007-03-18 Thread Gabriel Genellina
En Sat, 17 Mar 2007 08:09:16 -0300, imx <[EMAIL PROTECTED]> escribió: > Enviroment: WinXP sp2, python 2.5 > problem: click IDLE using shorcut menu or run phthonw.exe directly, > nothing happen! But running python.exe from the command line is fine. pythonw.exe does not open a window so it's almost

Re: Private data

2007-03-18 Thread Gabriel Genellina
En Sat, 17 Mar 2007 13:31:01 -0300, Dustan <[EMAIL PROTECTED]> escribió: > http://dustangroups.googlepages.com/privateattributesinpython > > This is something that I just threw together this morning, after a > eureka moment. It's a way of creating private class attributes and > static function v

Re: To count number of quadruplets with sum = 0

2007-03-18 Thread Jorge Godoy
"n00m" <[EMAIL PROTECTED]> writes: > my dial-up line's too slow for downloading 4mb of shedskin-0.0.20.exe Don't worry! We can email it to you. :-D -- Jorge Godoy <[EMAIL PROTECTED]> -- http://mail.python.org/mailman/listinfo/python-list

Re: Automagically log changes in table

2007-03-18 Thread Diez B. Roggisch
George Sakkis schrieb: > This is more in the context of Turbogears/SQLAlchemy, but if anyone > has implemented something similar with other packages it might be > useful to know. SQLObject since version 0.8 lets you define event listeners for create/update/delete events on objects. You could hook

Re: Private data

2007-03-18 Thread Steven D'Aprano
On Sat, 17 Mar 2007 09:31:01 -0700, Dustan wrote: > http://dustangroups.googlepages.com/privateattributesinpython > > This is something that I just threw together this morning, after a > eureka moment. It's a way of creating private class attributes and > static function variables (I'm not 100% s

Re: Private data

2007-03-18 Thread Dustan
On Mar 18, 5:26 am, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Sat, 17 Mar 2007 13:31:01 -0300, Dustan <[EMAIL PROTECTED]> > escribió: > > >http://dustangroups.googlepages.com/privateattributesinpython > > > This is something that I just threw together this morning, after a > > eureka mome

Re: GCC 4.1.2 installer for Python distutils compilation

2007-03-18 Thread David Rushby
On Mar 18, 5:08 am, Giovanni Bajo <[EMAIL PROTECTED]> wrote: > This page: >http://www.develer.com/oss/GccWinBinaries > > contains a friendly Windows installer for GCC 4.1.2 (MinGW binary version), > with full support for integrating it with Python installations so that it is > used by distutils

Re: Private data

2007-03-18 Thread Dustan
On Mar 18, 7:06 am, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Sat, 17 Mar 2007 09:31:01 -0700, Dustan wrote: > >http://dustangroups.googlepages.com/privateattributesinpython > > > This is something that I just threw together this morning, after a > > eureka moment. It's a way of creating priv

encoding - arabic(IBM 864) to UNICODE

2007-03-18 Thread Madhu Alagu
Hello, How to convert IBM 864,IBM 420 & Nafitha(Arabic) to UNICODE. Thanks Madhu Alagu -- http://mail.python.org/mailman/listinfo/python-list

Re: Private data

2007-03-18 Thread Dustan
On Mar 18, 7:17 am, "Dustan" <[EMAIL PROTECTED]> wrote: > On Mar 18, 5:26 am, "Gabriel Genellina" <[EMAIL PROTECTED]> > wrote: > > > > > En Sat, 17 Mar 2007 13:31:01 -0300, Dustan <[EMAIL PROTECTED]> > > escribió: > > > >http://dustangroups.googlepages.com/privateattributesinpython > > > > This is

Re: getopt or optparse options/arguments wrapping?

2007-03-18 Thread Rocky Zhou
nt/file/data/ -cnewer /var/ fs_backup/work/.ts ! -type d -print >>/tmp/fs_backup.work.incr. 1174221140.0.list 2007-03-18 20:32:20 fs_backup DEBUG find /mnt/file/work/ -cnewer /var/ fs_backup/work/.ts ! -type d -print >>/tmp/fs_backup.work.incr. 1174221140.0.list 2007-03-18 20:32:20 fs_back

Re: Automagically log changes in table

2007-03-18 Thread aspineux
On 18 mar, 04:20, "George Sakkis" <[EMAIL PROTECTED]> wrote: > On Mar 17, 7:59 pm, "aspineux" <[EMAIL PROTECTED]> wrote: > > > Hi > > > You can get this using "triggers" and "stored procedures". > > These are SQL engine dependent! This is available for long time with > > postgress and only from ver

Re: most complete xml package for Python?

2007-03-18 Thread [EMAIL PROTECTED]
On Mar 15, 5:45 pm, "Paul Boddie" <[EMAIL PROTECTED]> wrote: > > I can't remember exactly how I solved this within anXML/XSLT-heavy > Java-based framework, I just put a single space between: and then it kept the XML container-style as opposed to single-tag. -- http://mail.python.org/mailma

cheese shop: tagging and dating

2007-03-18 Thread [EMAIL PROTECTED]
The first thing I look at when examining a module is how often it is updated. Unfortunately, the entries there dont show this. Eg: http://www.python.org/pypi/PySimpleXML/1.0 Second, it seems that tagging is more popular than the hierarchical browsing method currently offered by Cheese Shop. Are

Re: Automagically log changes in table

2007-03-18 Thread Jorge Godoy
"aspineux" <[EMAIL PROTECTED]> writes: > On 18 mar, 04:20, "George Sakkis" <[EMAIL PROTECTED]> wrote: >> >> I'd rather avoid triggers since I may have to deal with Mysql 4. Apart >> from that, how can a trigger know the current user ? > > Because each user opening an web session will login to the

Re: encoding - arabic(IBM 864) to UNICODE

2007-03-18 Thread Jorge Godoy
"Madhu Alagu" <[EMAIL PROTECTED]> writes: > Hello, > > How to convert IBM 864,IBM 420 & Nafitha(Arabic) to UNICODE. Your OS should have some tools for that. On Linux I use 'iconv' to convert from several encodings to several other encodings. Another option is checking if Python has those encod

Re: cheese shop: tagging and dating

2007-03-18 Thread Jorge Godoy
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > The first thing I look at when examining a module is how often it is > updated. Unfortunately, the entries there dont show this. Eg: > > http://www.python.org/pypi/PySimpleXML/1.0 > > Second, it seems that tagging is more popular than the hierarc

Re: IDE for wxPython

2007-03-18 Thread Peter Decker
On 3/17/07, Ghirai <[EMAIL PROTECTED]> wrote: > Can anyone suggest an IDE for wxPython? > Or an IDE for TkInter? Don't know about Tkinter, but for wxPython, I would suggest Dabo. You get their visual tools, along with a more robust and consistent wrapper around the wxPython API. -- # p.d. --

[Help]UnicodeDecodeError

2007-03-18 Thread Karl
error msg: Mod_python error: "PythonHandler mod_python.publisher" Traceback (most recent call last): File "/usr/lib/python2.3/site-packages/mod_python/apache.py", line 299, in HandlerDispatch result = object(req) File "/usr/lib/python2.3/site-packages/mod_python/publisher.py", line 136,

Re: Private data

2007-03-18 Thread Dustan
On Mar 18, 7:25 am, "Dustan" <[EMAIL PROTECTED]> wrote: > On Mar 18, 7:06 am, Steven D'Aprano > > First, an example of the code in action. > > > >>> import PrivateAttributes > > >>> obj = PrivateAttributes.TestPrivateClassAttributes() > > >>> obj.getNumInstances() > > 1 > > >>> another = PrivateAtt

Re: encoding - arabic(IBM 864) to UNICODE

2007-03-18 Thread Peter Otten
Madhu Alagu wrote: > How to convert IBM 864,IBM 420 & Nafitha(Arabic) to UNICODE. You can treat them like every other encoding: >>> s = '\xe1\xec\xf0\xe8\xe1' # * >>> print s.decode("cp864") # convert from cp864 to unicode ﻓﻌﹽﻭﻓ >>> s.decode("cp864").encode("utf8") # convert from cp864 to utf-8

Re: Private data

2007-03-18 Thread Dustan
On Mar 18, 8:21 am, "Dustan" <[EMAIL PROTECTED]> wrote: > On Mar 18, 7:25 am, "Dustan" <[EMAIL PROTECTED]> wrote: > > > > > On Mar 18, 7:06 am, Steven D'Aprano > > > First, an example of the code in action. > > > > >>> import PrivateAttributes > > > >>> obj = PrivateAttributes.TestPrivateClassAttri

Re: [Help]UnicodeDecodeError

2007-03-18 Thread Peter Otten
Karl wrote: > error msg: > Mod_python error: "PythonHandler mod_python.publisher" > > Traceback (most recent call last): > > File "/usr/lib/python2.3/site-packages/mod_python/apache.py", line > 299, in HandlerDispatch > result = object(req) > > File "/usr/lib/python2.3/site-packages/mod

screen size/resolution in win32 in python

2007-03-18 Thread adri80386
Hi: How I can get the current screen resolution settings (screen.width and screen.heigth in pixels) in python. Thanks in advance Adrian -- http://mail.python.org/mailman/listinfo/python-list

Re: IDE for wxPython

2007-03-18 Thread Stef Mientki
Ghirai wrote: > Hello python-list, > > Can anyone suggest an IDE for wxPython? > Or an IDE for TkInter? > > Thanks. > on this site, you can test which GUI is best suited for your needs http://www.awaretek.com/toolkits.html I think it might be PyhtonCard -- cheers, Stef Mientki http://pic.flapp

Re: Mastering Python

2007-03-18 Thread Aahz
In article <[EMAIL PROTECTED]>, John Nagle <[EMAIL PROTECTED]> wrote: >Alex Martelli wrote: >> Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: >>> >>>Mastery and quickly are opposing terms Took me 15 years on a job >>>using FORTRAN 77 and I still wouldn't have called myself a master. (I'm >>>more of

Re: cannot start IDLE in WinXP

2007-03-18 Thread imx
On 3月18日, 下午5时47分, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Sat, 17 Mar 2007 08:09:16 -0300, imx <[EMAIL PROTECTED]> escribió: > > > Enviroment: WinXP sp2, python 2.5 > > problem: click IDLE using shorcut menu or run phthonw.exe directly, > > nothing happen! But running python.exe from t

Re: Webcams and python

2007-03-18 Thread Synt4x
On 18 mar, 04:24, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > In <[EMAIL PROTECTED]>, Synt4x wrote: > > from VideoCapture import Device > > cam = Device() > > > while 1: > > img = cam.getImage() > > > Now, by doing this, my processor fires up to 100% load, which > > obviously makes my

Re: GCC 4.1.2 installer for Python distutils compilation

2007-03-18 Thread Giovanni Bajo
On 18/03/2007 13.24, David Rushby wrote: > Even though I have access to MSVC 7.1, so I don't really need MinGW > myself, [...] But remember that GCC 4.1.2 is almost 4 years newer than MSVC 7.1, and I found it to produce more optimized code (especially for C++). Since it's a free alternative, it

XML based programming language

2007-03-18 Thread stefaan
Hello, I have recently had to deal with an XML-based programming language. (The programs are generated programmatically.) XML leads to a "two-level" parsing problem: first parse the xml into tokens, then parse the tokens to grasp their meaning (based on the semantics of the programming language).

Re: XML based programming language

2007-03-18 Thread Diez B. Roggisch
stefaan schrieb: > Hello, > > I have recently had to deal with an XML-based > programming language. (The programs are > generated programmatically.) > > XML leads to a "two-level" parsing problem: first > parse the xml into tokens, then parse the tokens > to grasp their meaning (based on the sema

list comprehension help

2007-03-18 Thread [EMAIL PROTECTED]
Hi I need to process a really huge text file (4GB) and this is what i need to do. It takes for ever to complete this. I read some where that "list comprehension" can fast up things. Can you point out how to do it in this case? thanks a lot! f = open('file.txt','r') for line in f: db[line.

pyCairo

2007-03-18 Thread Jim
I'd like to experiment with pyCairo, but I'm having installation problems. I've downloaded cairo 1.4.0, libpng 1.2.8, zlib 1.2.3, and pycairo 1.4.0, and I've placed the DLLs for cairo, libpng, and zlib in c:\python25\dlls\. However, when I run "setup.py install" I get an error message saying that

Re: list comprehension help

2007-03-18 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, [EMAIL PROTECTED] wrote: > I need to process a really huge text file (4GB) and this is what i > need to do. It takes for ever to complete this. I read some where that > "list comprehension" can fast up things. Can you point out how to do > it in this case? No way I can see

Re: screen size/resolution in win32 in python

2007-03-18 Thread Tim Golden
adri80386 wrote: > Hi: > > How I can get the current screen resolution settings (screen.width and > screen.heigth in pixels) in python. You want the GetSystemMetrics function from the pywin32 packge: from win32api import GetSystemMetrics print "width =", GetSystemMetrics (0) print "height =",Ge

Re: list comprehension help

2007-03-18 Thread Daniel Nogradi
> I need to process a really huge text file (4GB) and this is what i > need to do. It takes for ever to complete this. I read some where that > "list comprehension" can fast up things. Can you point out how to do > it in this case? > thanks a lot! > > > f = open('file.txt','r') > for line in f: >

Re: list comprehension help

2007-03-18 Thread [EMAIL PROTECTED]
On 3/18/07, Daniel Nogradi <[EMAIL PROTECTED]> wrote: > > I need to process a really huge text file (4GB) and this is what i > > "list comprehension" can fast up things. Can you point out how to do > > f = open('file.txt','r') > > for line in f: > > db[line.split(' ')[0]] = line.split(' ')[

Re: list comprehension help

2007-03-18 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Daniel Nogradi wrote: >> f = open('file.txt','r') >> for line in f: >> db[line.split(' ')[0]] = line.split(' ')[-1] >> db.sync() > > What is db here? Looks like a dictionary but that doesn't have a sync method. Shelves (`shelve` module) have this API. And

Re: list comprehension help

2007-03-18 Thread [EMAIL PROTECTED]
On 3/18/07, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > In <[EMAIL PROTECTED]>, Daniel Nogradi > wrote: > > >> f = open('file.txt','r') > >> for line in f: > >> db[line.split(' ')[0]] = line.split(' ')[-1] > >> db.sync() > > > > What is db here? Looks like a dictionary but

Re: list comprehension help

2007-03-18 Thread Daniel Nogradi
> > > I need to process a really huge text file (4GB) and this is what i > > > "list comprehension" can fast up things. Can you point out how to do > > > f = open('file.txt','r') > > > for line in f: > > > db[line.split(' ')[0]] = line.split(' ')[-1] > > > db.sync() > > > > What is

Re: Finding the insertion point in a list

2007-03-18 Thread 7stud
On Mar 18, 2:23 am, Paul Rubin wrote: > Steve Holden <[EMAIL PROTECTED]> writes: > > >max(i for i,t in enumerate(x) if t <= y) > > > Those are actually pretty direct. > > > How about a solution (like the bisect one suggested almost as soon as > > this thread started)

Re: Finding the insertion point in a list

2007-03-18 Thread Alex Martelli
7stud <[EMAIL PROTECTED]> wrote: > On Mar 18, 2:23 am, Paul Rubin wrote: > > Steve Holden <[EMAIL PROTECTED]> writes: > > > >max(i for i,t in enumerate(x) if t <= y) > > > > Those are actually pretty direct. > > > > > How about a solution (like the bisect one suggest

Re: Still the __new__ hell ...

2007-03-18 Thread Paulo da Silva
Arnaud Delobelle escreveu: > On Mar 17, 11:48 pm, Paulo da Silva <[EMAIL PROTECTED]> wrote: >> Arnaud Delobelle escreveu:> On Mar 17, 9:31 pm, Paulo da Silva <[EMAIL >> PROTECTED]> wrote: > > [snip] > >> Thanks. This works exactly the way you wrote. >> Yet I am misunderstanding something. Can't

Re: list comprehension help

2007-03-18 Thread Alex Martelli
[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > On 3/18/07, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > > In <[EMAIL PROTECTED]>, Daniel Nogradi > > wrote: > > > > >> f = open('file.txt','r') > > >> for line in f: > > >> db[line.split(' ')[0]] = line.split(' ')[-1] > > >>

Re: encoding - arabic(IBM 864) to UNICODE

2007-03-18 Thread Mohammad Tayseer
text_864 = "\xd1" unicode_string = unicode(text_864, encoding="cp864") # cp864 = IBM 864 The above code is working with Python 2.4. Unfortunately, it doesn't support IBM 420 & Nafitha. The mapping between IBM 864 and unicode is in Lib/encodings & the file is very simple. You can add your own ea

Optimization problem

2007-03-18 Thread cesco
I have a set of N blocks of different lengths. The length of each block is a multiple of a basic unit. The blocks, once lined up, make a path of distance equal to R. Let's say we have 5 blocks with the following lengths: N_set_lengths = (1, 3, 2, 1, 3), then the path we cover by lining them up is e

Re: Eureka moments in Python

2007-03-18 Thread Mohammad Tayseer
> I'd be interested in hearing people's stories of Eureka moments > in Python, moments where you suddenly realise that some task > which seemed like it would be hard work was easy with Python. I had a project in the faculty where we were supposed to implement a compiler for a very simple lang

Re: Webcams and python

2007-03-18 Thread sturlamolden
On Mar 18, 3:41 pm, "Synt4x" <[EMAIL PROTECTED]> wrote: > The problem with adding a sleep() instrucction is that the "video > feed" looks lagged, if you know what I mean. It looks interrupted. You could try win32api.Sleep(0) instead, which will release the reminder of the time slice. -- http://

Re: How to get the previous line in a file?

2007-03-18 Thread Mel Wilson
Qilong Ren wrote: > Hi, Shane, > > Thanks for fast reply. > > What I used is : >for line in open(FILE): > > I don't want to store all lines in a list because sometimes the file is very > large. We need to store the value of the previous line in a variable. Is that > right?

Re: Webcams and python

2007-03-18 Thread Synt4x
On 18 mar, 14:17, "sturlamolden" <[EMAIL PROTECTED]> wrote: > On Mar 18, 3:41 pm, "Synt4x" <[EMAIL PROTECTED]> wrote: > > > The problem with adding a sleep() instrucction is that the "video > > feed" looks lagged, if you know what I mean. It looks interrupted. > > You could try win32api.Sleep(0) in

Renaming or Overloading In Python

2007-03-18 Thread gamename
Hi, I'm a recent convert from TCL. One of the more powerful aspects of TCL is the ability to rename a function at will (generally for testing purposes). Example from the tcl doc: rename ::source ::theRealSource set sourceCount 0 proc ::source args { global sourceCount puts "called sourc

Re: Optimization problem

2007-03-18 Thread mkPyVS
I would suggest taking a look at the python package networkx. It is a wonderfully created path optimization and presentation package which has a fair amount of extensabilty. Basic lowest cost path solutions should be able to solve your algorithmic needs here in polynomial time (Typically N**P time

Re: Renaming or Overloading In Python

2007-03-18 Thread Diez B. Roggisch
gamename schrieb: > Hi, > > I'm a recent convert from TCL. One of the more powerful aspects of > TCL is the ability to rename a function at will (generally for testing > purposes). > > Example from the tcl doc: > > rename ::source ::theRealSource > set sourceCount 0 > proc ::source args { >

Re: Renaming or Overloading In Python

2007-03-18 Thread Paul McGuire
On Mar 18, 2:17 pm, "gamename" <[EMAIL PROTECTED]> wrote: > Hi, > > I'm a recent convert from TCL. One of the more powerful aspects of > TCL is the ability to rename a function at will (generally for testing > purposes). > > Example from the tcl doc: > > rename ::source ::theRealSource > set sourc

Re: getopt or optparse options/arguments wrapping?

2007-03-18 Thread Steven Bethard
Rocky Zhou wrote: > .dirs .files is just a snapshot of the current directories, which can > be used to delete-outdated files when restoring. Here I used absolute > path by using tar's -P parameter. When fs_rstore, it will do this: > command = "tar -xpz -P -f %s.tgz -T %s" % (archive, self.t_files)

Stuck with pyqt: can't get/read button IDs from a qbuttongroup

2007-03-18 Thread raacampbell
Hi, I'm learning Python and QT and have set myself the task of writing a simple calculator applet. I'm using Qt3 and with the designer have made a button group which contains 10 buttons to allow the user to press the digits 0 to 9. The idea is that the button group is associated with a single slo

Re: Stuck with pyqt: can't get/read button IDs from a qbuttongroup

2007-03-18 Thread raacampbell
> which translates to this in the .py: > def getNumber(self,a0): > self.listBox1.insertItem(str(id)) > As is typically the way with these things, I've just solved it. I changed the text in the file generated by pyui. It now reads: def getNumber(self,a0): self.listBox1.ins

Re: lock problem

2007-03-18 Thread Leo Kislov
On Mar 16, 3:08 pm, Ritesh Raj Sarraf <[EMAIL PROTECTED]> wrote: > Leo Kislov wrote: > > But you miss the fact that there is only one environment per process. > > Maybe there's a confusion. > The environment variable that I'm setting has noting to do with ldapsearch. I > use the environment variabl

Re: Webcams and python

2007-03-18 Thread sturlamolden
On Mar 18, 8:01 pm, "Synt4x" <[EMAIL PROTECTED]> wrote: > I haven't been able to find the win32api extension, but i've read on > the web that time.sleep() calls win32api.Sleep(). I tested VideoCapture using PyGame to draw the graphics. PyGame wraps SDL which uses DirectDraw on Windows. I don't t

* operator--as in *args?

2007-03-18 Thread 7stud
Hi, I can't find any documentation for the * operator when applied in front of a name. Is it a pointer? What about the @ operator? Are there python names for these operators that would make searching for documentation on them more fruitful? Thanks -- http://mail.python.org/mailman/listinfo/p

Re: cheese shop: tagging and dating

2007-03-18 Thread Richard Jones
Jorge Godoy wrote: > "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: >> The first thing I look at when examining a module is how often it is >> updated. Unfortunately, the entries there dont show this. Eg: >> >> http://www.python.org/pypi/PySimpleXML/1.0 >> >> Second, it seems that tagging is mor

Re: list comprehension help

2007-03-18 Thread cptnwillard
I wonder whether the following be more efficient if DB was a dictionnary: Splits = (line.split(' ') for line in open('file.text', 'r')) DB = dict([(S[0], S[-1]) for S in Splits]) -- http://mail.python.org/mailman/listinfo/python-list

Re: * operator--as in *args?

2007-03-18 Thread Dustan
On Mar 18, 3:53 pm, "7stud" <[EMAIL PROTECTED]> wrote: > Hi, > > I can't find any documentation for the * operator when applied in > front of a name. Is it a pointer? > > What about the @ operator? > > Are there python names for these operators that would make searching > for documentation on them

Building several parsing modules

2007-03-18 Thread Robert Neville
Basically, I want to create a table in html, xml, or xslt; with any number of regular expressions; a script (Perl or Python) which reads each table row (regex and replacement); and performs the replacement on any file name, folder, or text file (e.g. css, php, html). For example, I often rename my

python QT or python-GTK

2007-03-18 Thread Jon Van DeVries
** All the posts found in google are old. I'm assuming new improvements have been made to both IDEs. ** Please correct me if I'm wrong, I'm a newbie. 1. Which one of them requires fewer lines to accomplish the same thing? from what I understand QT it's just like Borland J-Builder. Meaning, you

Re: python QT or python-GTK

2007-03-18 Thread Phil Thompson
On Sunday 18 March 2007 9:55 pm, Jon Van DeVries wrote: > ** All the posts found in google are old. I'm assuming new improvements > have been made to both IDEs. ** > > Please correct me if I'm wrong, I'm a newbie. > > 1. Which one of them requires fewer lines to accomplish the same thing? > from w

Re: Grep Equivalent for Python

2007-03-18 Thread tereglow
On Mar 15, 1:47 am, [EMAIL PROTECTED] (Alex Martelli) wrote: > tereglow <[EMAIL PROTECTED]> wrote: > >... > > > server using the /proc FS. For example, in order to obtain the amount > > of physical memory on the server, I would do the following in shell: > > >grep^MemTotal /proc/meminfo | awk

Trying to print from inside a method

2007-03-18 Thread AWasilenko
I'm still in the process of learning python via a handful of books I bought. One book I am reading just introduced Base Class Methods. I found that I needed more understanding on this concept and wrote a short test program using the Author's code as a vague reference. My question now really isn'

where function

2007-03-18 Thread vorticitywolfe
Is there a function in Python analogous to the "where" function in IDL? x=[0,1,2,3,4,2,8,9] print where(x=2) output: [2,5] -- http://mail.python.org/mailman/listinfo/python-list

fifo queue

2007-03-18 Thread drochom
hi, how would u improve this code? class queue: def __init__(self, size=8): self.space = size self.data = [None]*self.space self.head = 0 self.tail = 0 self.len = 0 def __len__(self): return self.len def push(self, x): if self.len==self.

Re: where function

2007-03-18 Thread bearophileHUGS
vorticitywo: > Is there a function in Python analogous to the "where" function in > IDL? Python gives very elastic syntax, you can simply do: data = [0,1,2,3,4,2,8,9] print [pos for pos, el in enumerate(data) if el==2] Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list

Re: where function

2007-03-18 Thread drochom
On 18 Mar, 15:19, [EMAIL PROTECTED] wrote: > Is there a function in Python analogous to the "where" function in > IDL? > > x=[0,1,2,3,4,2,8,9] > print where(x=2) > > output: > [2,5] You can try this: print filter( lambda x: a[x]==2, range(len(a))) However it's not the best solution... -- http:

Re: fifo queue

2007-03-18 Thread Paul Rubin
Unless the queue is really large, just use the pop operation to get stuff off the top of the queue. That causes O(n) operations but it should be fast if n is small. class queue(list): push = append def pop(self): return list.pop(self,0) should do about what you wr

Re: where function

2007-03-18 Thread vorticitywolfe
On Mar 18, 10:48 pm, [EMAIL PROTECTED] wrote: > vorticitywo: > > > Is there a function in Python analogous to the "where" function in > > IDL? > > Python gives very elastic syntax, you can simply do: > > data = [0,1,2,3,4,2,8,9] > print [pos for pos, el in enumerate(data) if el==2] > > Bye, > bearo

Re: where function

2007-03-18 Thread Shane Geiger
a = [0,1,2,3,4,2,8,9]

Re: where function

2007-03-18 Thread Steven Bethard
[EMAIL PROTECTED] wrote: > Is there a function in Python analogous to the "where" function in > IDL? > > x=[0,1,2,3,4,2,8,9] > print where(x=2) > > output: > [2,5] If you're doing a lot of this kind of thing, you probably want to use numpy:: >>> import numpy >>> x = numpy.array([0, 1

Re: where function

2007-03-18 Thread Scott David Daniels
[EMAIL PROTECTED] wrote: > On Mar 18, 10:48 pm, [EMAIL PROTECTED] wrote: >> [...fine solutions to the problem as asked...] > Thank you both, a little more cumbersome than I expected, but it does > the job! Thanks! The obvious simple near-equivalent is: data = range(33,99) print data.ind

Re: fifo queue

2007-03-18 Thread Roel Schroeven
drochom schreef: > hi, > > how would u improve this code? > > class queue: > ... I think I'd use collections.deque [1] instead of using a ring buffer as you're doing (I think) and doing a lot of manual bookkeeping. [1] http://docs.python.org/lib/deque-objects.html -- If I have been able t

Re: Grep Equivalent for Python

2007-03-18 Thread Aahz
In article <[EMAIL PROTECTED]>, tereglow <[EMAIL PROTECTED]> wrote: >On Mar 15, 1:47 am, [EMAIL PROTECTED] (Alex Martelli) wrote: >> tereglow <[EMAIL PROTECTED]> wrote: >>> >>>grep^MemTotal /proc/meminfo | awk '{print $2}' >> >> If you would indeed do that, maybe it's also worth learning something

Re: Trying to print from inside a method

2007-03-18 Thread Alex Martelli
<[EMAIL PROTECTED]> wrote: > I'm still in the process of learning python via a handful of books I > bought. One book I am reading just introduced Base Class Methods. I I believe your problem may be more basic: local variables, istance attributes, and class variables, are very separate things.

Re: fifo queue

2007-03-18 Thread Alex Martelli
Paul Rubin wrote: > Unless the queue is really large, just use the pop operation to get > stuff off the top of the queue. That causes O(n) operations but it > should be fast if n is small. > > class queue(list): > push = append > def pop(self): >

Re: list comprehension help

2007-03-18 Thread George Sakkis
On Mar 18, 1:40 pm, [EMAIL PROTECTED] (Alex Martelli) wrote: > [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > On 3/18/07, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > > > In <[EMAIL PROTECTED]>, Daniel Nogradi > > > wrote: > > > > >> f = open('file.txt','r') > > > >> for line in f: > > >

Re: list comprehension help

2007-03-18 Thread Alex Martelli
George Sakkis <[EMAIL PROTECTED]> wrote: ... > > Unless each line is huge, how exactly you split it to get the first and > > last blank-separated word is not going to matter much. > > > > Still, you should at least avoid repeating the splitting twice, that's > > pretty obviously sheer waste: so,

Re: list comprehension help

2007-03-18 Thread Alex Martelli
f<[EMAIL PROTECTED]> wrote: > I wonder whether the following be more efficient if DB was a > dictionnary: > > Splits = (line.split(' ') for line in open('file.text', 'r')) > DB = dict([(S[0], S[-1]) for S in Splits]) You'd still be doing much more splitting work (and behind-the-scene allocation

Re: Renaming or Overloading In Python

2007-03-18 Thread Alex Martelli
gamename <[EMAIL PROTECTED]> wrote: > Hi, > > I'm a recent convert from TCL. One of the more powerful aspects of > TCL is the ability to rename a function at will (generally for testing > purposes). > > Example from the tcl doc: > > rename ::source ::theRealSource > set sourceCount 0 > proc ::

Re: Trying to print from inside a method

2007-03-18 Thread AWasilenko
On Mar 18, 7:32 pm, [EMAIL PROTECTED] (Alex Martelli) wrote: > Here, the message1 and message2 names are LOCAL variables of the > respective methods: each disappear as soon as its method ends. > > If you want to make them into INSTANCE attributes, so they'll stick > around for later, assign to self

Re: python QT or python-GTK

2007-03-18 Thread Alan Franzoni
Il Sun, 18 Mar 2007 11:55:47 -1000, Jon Van DeVries ha scritto: > Please correct me if I'm wrong, I'm a newbie. Please understand then, that both QT and GTK+ are graphic toolkits. An IDE is a totally different thing. Also, please understand that Qt3 and Qt4 exist, and they're quite different bea

Re: Trying to print from inside a method

2007-03-18 Thread Alex Martelli
<[EMAIL PROTECTED]> wrote: ... > > This would be pretty weird, but legal Python. > > Weirder and weirder, but still legal Python. > > This is usually how most of my code turns out :( I'm afraid if I ever > learn enough > to make a serious program I will be burned at the stake for such un- > py

Re: Private data

2007-03-18 Thread Gabriel Genellina
En Sun, 18 Mar 2007 10:21:27 -0300, Dustan <[EMAIL PROTECTED]> escribió: dis.dis(testPrivateStaticFunctionVariables) > 21 0 LOAD_DEREF 0 (func) > 3 LOAD_DEREF 1 (internalData) > 6 LOAD_FAST0 (args) >

Re: [Edu-sig] minimum age to learn python (a.k.a graphical vs text languages)

2007-03-18 Thread Peter Chase
I used to judge science fairs in the DC area. There were junior and senior divisions, and the junior division age range was from 6th to 9th grades. At the time I got the occasional project written in Basic, many of which were very interesting. I would think that Python would easily outclass

Re: * operator--as in *args?

2007-03-18 Thread 7stud
On Mar 18, 3:40 pm, "Dustan" <[EMAIL PROTECTED]> wrote: > For example: > aFunction(*(1,2,3)) > is equivalent to: > aFunction(1,2,3) > That's the context I've seen it in, but written like this: someFunc(*args) I played around with it a little bit, and it appears the * operator unpacks a list, tup

Re: * operator--as in *args?

2007-03-18 Thread Alex Martelli
7stud <[EMAIL PROTECTED]> wrote: > On Mar 18, 3:40 pm, "Dustan" <[EMAIL PROTECTED]> wrote: > > For example: > > aFunction(*(1,2,3)) > > is equivalent to: > > aFunction(1,2,3) > > > > That's the context I've seen it in, but written like this: > > someFunc(*args) > > I played around with it a lit

Re: * operator--as in *args?

2007-03-18 Thread Gabriel Genellina
En Sun, 18 Mar 2007 18:40:32 -0300, Dustan <[EMAIL PROTECTED]> escribió: >> I can't find any documentation for the * operator when applied in >> front of a name. Is it a pointer? > > For the *star, see apply here: > http://docs.python.org/lib/non-essential-built-in-funcs.html Also, you can rea

Re: * operator--as in *args?

2007-03-18 Thread Gabriel Genellina
En Sun, 18 Mar 2007 22:21:41 -0300, Alex Martelli <[EMAIL PROTECTED]> escribió: > 7stud <[EMAIL PROTECTED]> wrote: > >> I played around with it a little bit, and it appears the * operator >> unpacks a list, tuple, or dictionary so that each element of the >> container gets assigned to a different

4 bytes to int

2007-03-18 Thread Andres Martinelli
Hello. Im new in the list, and really new in python. My simple question is: I have an array of 4 bytes, and I want to convert it to the int they form. How do you do that? :s I've looking throw the web, but with no success. Hope you can help. Andres M. -- http://mail.python.org/mailman/listinfo

Re: list comprehension help

2007-03-18 Thread George Sakkis
On Mar 18, 12:11 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Hi > I need to process a really huge text file (4GB) and this is what i > need to do. It takes for ever to complete this. I read some where that > "list comprehension" can fast up things. Can you point out how to do > it in this

  1   2   >