Re: Dictionary question.

2005-04-23 Thread bserviss
A simple way to get individual values for the distribution is: d = {} for i in range( 0, 1000): j = random.randrange( 0, 100) if d.has_key(j): d[j] += 1 else: d[j] = 1 keys = d.keys() keys.sort() for key in keys: print key, ":", "*" * d[key] -- http://mail.pytho

Re: a=[ lambda t: t**n for n in range(4) ]

2005-04-23 Thread mehmetmutigozel
Thanx. It just popped in my mind. in 3d programming there are transformation matrices like a=[[cos(x),sin(x),0],[-sin(x),cos(x),0],[0,0,1]] it is a 3x3 matrix. never changes during program. it can be defined like >>> def transmat(x): ... dummy=[[0,0,0],[0,0,0],[0,0,0]] ... d

Re: c-extension crashes unexpected

2005-04-23 Thread Markus Wintermann
John Machin schrieb: > ... > > Some suggestions: > > 1. Try Pyrex. You get to write in a higher-level language and it does > all the boring ugly error-prone stuff for you -- this includes > reference counting as well! Look at the C code that Pyrex generates, > to see what Pyrex is saving you from

Re: trying to read from dying disk

2005-04-23 Thread Ivan Van Laningham
Hi All-- [EMAIL PROTECTED] wrote: > > I'm currently attempting something with > > http://www.python.org/doc/current/lib/node368.html > > but it seems the read operation is ignoring these signals just as it is > ignoring my signals from the kill command -- perhaps unsurprisingly. > > Perhaps

Re: Python licence again

2005-04-23 Thread has
John J. Lee wrote: > Yes. ISTR that licence is a British English spelling, though my > British brain has been thoroughly contaminated by US spellings and > usage by now. Oh, it only gets worse: a couple years on the illiterate intarweb and even basics like "its" and "it's" become a major struggle

Re: PDF Printing support from Python

2005-04-23 Thread Mike Meyer
"dcrespo" <[EMAIL PROTECTED]> writes: > Hi Grant Edwards... > > Your solution requires a previous installation of Acrobat. Internally, > the OS is sending the pdf file to the Acrobat PDF Driver and then it is > sent to the printer. So you have to have Acrobat installed. Don't you? No, you don't.

Re: __init__.py question

2005-04-23 Thread Terry Hancock
On Friday 22 April 2005 07:19 am, codecraig wrote: > Ok, I have the following directory structure > > C:\pycode >--> blah.py >--> mynewdir > --> __init__.py > --> abc.py > > [[ C:\pycode\mynewdir\abc.py ]] > > def doFoo(): > print "hi" > > def doBar(): > print "bye"

Re: a=[ lambda t: t**n for n in range(4) ]

2005-04-23 Thread Bengt Richter
On 22 Apr 2005 15:18:53 -0700, [EMAIL PROTECTED] wrote: >Thanx for your replies. > >I'm looking for array of functions. >Something like a=[ sin(x) , cos(x) ] > x=0.0 a >[0, 1] x=1.0 a >... > >of course it can be made by def cratearray(x): >... >...

Re: Semi-newbie, rolling my own __deepcopy__

2005-04-23 Thread [EMAIL PROTECTED]
Michael Spencer wrote: > [EMAIL PROTECTED] wrote: > > I'm back... > [wondering why copy.deepcopy barfs on array instances] > > > > http://www.python.org/doc/2.3.3/lib/module-copy.html > deepcopy: > ... > This version does not copy types like module, class, function, method, stack > trace, stack fra

Re: Run Unix shell command $ parse command line arguments in python

2005-04-23 Thread Terry Hancock
On Friday 22 April 2005 01:39 am, [EMAIL PROTECTED] wrote: > I am a newbie to python. I have a makefile which i can compile in > UNIX/LINUX, But i > I am planning to write a python script which actually does what my > MAKEFILE does. The make file is [...] > I want to write a python script to r

Re: How to run Python in Windows w/o popping a DOS box?

2005-04-23 Thread pyguy2
>>I think of it like the ''.join semantics. The object knows best how to >>handle join (even if it looks wierd to some people). In the #! case, >>the program knows best how to start itself. >This I don't understand ;-) With ','.join(['a','b','c'])You rely on what wants to join the sequence t

Re: a=[ lambda t: t**n for n in range(4) ]

2005-04-23 Thread Mage
Scott David Daniels wrote: > > > See, the body of your anonymous function just looks for "the current > value of n" when it is _invoked_, not when it is _defined_. The "lambda functions" was an unclear part of the tutorial I read. Should I use them? Are they pythonic? As far I see they are good o

Decorator pattern for new-style classes ?

2005-04-23 Thread George Sakkis
Searching the archives for something related to the title, I found a few relevant threads (e.g. http://tinyurl.com/avyg6 or http://tinyurl.com/b5b6v); however they don't seem to give a satisfactory answer, so here it goes again: What's the equivalent new-style Delegate class ? class Delegate:

Re: Python Imaging Library and PyGTK - color image path?

2005-04-23 Thread Fredrik Lundh
Jeremy Bowers wrote: I have an image in the Python Image Library. I'm trying to get it into PyGTK in color. Is there any way to do this cross-platform, preferably without writing to anything to the disk? PIL apparently can't write XPMs. GTK will only take XPMs, that I can see. Therein lies the rub.

Re: In defense of Visual Basic (was Re: Why Python does *SLICING* theway it does??)

2005-04-23 Thread Fredrik Lundh
"[EMAIL PROTECTED]" wrote: Sub print_matrix(xmat() As Double) Debug.Print UBound(xmat, 1), UBound(xmat, 2) 'do stuff with xmat End Sub It is trivial to allocate and pass multidimensional arrays in VBA, but C requires expertise with pointers. The subroutine print_matrix can query the dimensions of x

tracing function calls

2005-04-23 Thread Stormbringer
Greetings, I've been wondering if there is a mechanism similar to trace/untrace found in lisp, for example call trace(function-name) and whenever this function is called it will show its parameters to stdout -- http://mail.python.org/mailman/listinfo/python-list

Re: tracing function calls

2005-04-23 Thread Fredrik Lundh
"Stormbringer" wrote: I've been wondering if there is a mechanism similar to trace/untrace found in lisp, for example call trace(function-name) and whenever this function is called it will show its parameters to stdout def trace(func): def tracer(*args, **kwargs): print func.__name__

Question Regarding PIL and PhotoImage classes

2005-04-23 Thread Harlin Seritt
Why is that I can only get the PhotoImage class to show up when I write a straight procedural script (no object orientation) but not when I try to use object-orientation? These two scripts in theory should produce the same results but they don't. Is there any reason why? ---Procedural--- roo

embedding python onto a fox-board

2005-04-23 Thread Floris van Manen
Is there anyone who already ported python onto a acme-systems linux fox-board? http://www.acmesystems.it/ -- http://mail.python.org/mailman/listinfo/python-list

Re: a=[ lambda t: t**n for n in range(4) ]

2005-04-23 Thread tiissa
[EMAIL PROTECTED] wrote: i wonder if there is an automatic way to make that without calling a function. You mean without _explicitely_ calling a function. May I inquire why you need to write f instead of f(x)? an automatic way that depends on changing the value of x. as each time x=something used t

Re: Question Regarding PIL and PhotoImage classes

2005-04-23 Thread Fredrik Lundh
Harlin Seritt wrote: Why is that I can only get the PhotoImage class to show up when I write a straight procedural script (no object orientation) but not when I try to use object-orientation? These two scripts in theory should produce the same results but they don't. Is there any reason why? in the

Re: tracing function calls

2005-04-23 Thread Stormbringer
Thank you Fredrik ! With a little tweaking for the right indentation it should prove useful :) Fredrik Lundh wrote: > "Stormbringer" wrote: > > > I've been wondering if there is a mechanism similar to trace/untrace > > found in lisp, for example call trace(function-name) and whenever this > > func

Python or PHP?

2005-04-23 Thread Lad
Is anyone capable of providing Python advantages over PHP if there are any? Cheers, L. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python or PHP?

2005-04-23 Thread Leif B. Kristensen
Lad skrev: > Is anyone capable of providing Python advantages over PHP if there are > any? Much more compact and yet much more readable code, making it easier to maintain and extend your programs. -- Leif Biberg Kristensen http://solumslekt.org/ -- http://mail.python.org/mailman/listinfo/python

Re: Python or PHP?

2005-04-23 Thread Leif K-Brooks
Lad wrote: Is anyone capable of providing Python advantages over PHP if there are any? Python is a programming language in more ways than simple Turing completeness. PHP isn't. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python callbacks & PyGILState_Release()

2005-04-23 Thread Thomas Heller
Randall Hopper <[EMAIL PROTECTED]> writes: > What is the correct way to propagate exceptions from Python callbacks? > > When I do this: > > Python -> C++ -> Python Callback > > (example attached) an exception raised in the callback doesn't make it back > across C++ to Python. > >

XML file parsing with SAX

2005-04-23 Thread Willem Ligtenberg
I decided to use SAX to parse my xml file. But the parser crashes on: File "/usr/lib/python2.3/site-packages/_xmlplus/sax/handler.py", line 38, in fatalError raise exception xml.sax._exceptions.SAXParseException: NCBI_Entrezgene.dtd:8:0: error in processing external entity reference This i

Re: PDF Printing support from Python

2005-04-23 Thread Diez B. Roggisch
> You're use of the word "driver" is one with which I'm not > familiar. But I don't really "do windows" so it's probably a > Widnowism. It could be that he means that creating PDFs on windows is done using a fake printer that will produce the pdf when being printed to - and that fake printer is i

Re: Python or PHP?

2005-04-23 Thread Mage
Lad wrote: >Is anyone capable of providing Python advantages over PHP if there are >any? > > I am also new to python but I use php for 4 years. I can tell: - python is more *pythonic* than php - python has its own perfume http://www.1976.com.tw/image/trussardi_python_uomo.jpg and it's nice. ph

Re: Python callbacks & PyGILState_Release()

2005-04-23 Thread Randall Hopper
Thomas Heller: |> Python -> C++ -> Python Callback |> |> (example attached) an exception raised in the callback doesn't make it back |> across C++ to Python. ... |> void callback_wrapper( void *user_data ) |> { |> // Acquire interpreter lock |> PyGILState_STATE gstate = PyGILState_

Re: PDF Printing support from Python

2005-04-23 Thread Grant Edwards
On 2005-04-23, Diez B. Roggisch <[EMAIL PROTECTED]> wrote: >> You're use of the word "driver" is one with which I'm not >> familiar. But I don't really "do windows" so it's probably a >> Widnowism. > > It could be that he means that creating PDFs on windows is > done using a fake printer that wil

Re: a=[ lambda t: t**n for n in range(4) ]

2005-04-23 Thread Harald Massa
Mage <[EMAIL PROTECTED]> wrote in news:mailman.2339.1114242211.1799.python- > The "lambda functions" was an unclear part of the tutorial I read. > Should I use them? Are they pythonic? > As far I see they are good only for type less a bit. And to obfusicate code. lambda is evil, do not play with

Re: a=[ lambda t: t**n for n in range(4) ]

2005-04-23 Thread Scott David Daniels
Mage wrote: Scott David Daniels wrote: See, the body of your anonymous function just looks for "the current value of n" when it is _invoked_, not when it is _defined_. The "lambda functions" was an unclear part of the tutorial I read. Should I use them? Are they pythonic? As far I see they are good

Caching compiled regexps across sessions (was Re: Regular Expressions - Python vs Perl)

2005-04-23 Thread Ville Vainio
> "Ilpo" == Ilpo NyyssÃnen writes: >> so you picked the wrong file format for the task, and the slowest Ilpo> What would you recommend instead? Ilpo> I have searched alternatives, but somehow I still find XML Ilpo> the best there is. It is a standard format with standard

Re: Frog 1.4 (web log aka blogging server)

2005-04-23 Thread Irmen de Jong
limodou wrote: great! How about change the bbcode like editor to FCKeditor? I think FCKeditor is much better, or make it as an optional editor which the user could select it himself. Isn't that pretty heavyweight for a blog? I mean; Frog is not a CMS with which you write HTML pages... Then again, i

Re: Python or PHP?

2005-04-23 Thread Ville Vainio
> "Leif" == Leif K-Brooks <[EMAIL PROTECTED]> writes: Leif> Lad wrote: >> Is anyone capable of providing Python advantages over PHP if there are >> any? Leif> Python is a programming language in more ways than simple Turing Leif> completeness. PHP isn't. +1 QOTW. -- Vil

Re: Python or PHP?

2005-04-23 Thread Diez B. Roggisch
> php doesn't have any smell au contraire! I've seen many code smells in PHP. http://c2.com/cgi/wiki?CodeSmell -- Regards, Diez B. Roggisch -- http://mail.python.org/mailman/listinfo/python-list

Re: Trouble Installing TTX/FontTools (asks for .NET Framework Packages)

2005-04-23 Thread Jesper Olsen
weston wrote: > This problem may be addressed here: > > http://sourceforge.net/mailarchive/message.php?msg_id=1702374 > > Apparently setup.py tries to compile a c file, which of course doesn't > work if there's no compiler. In fact it does not work even if there is a compiler - seems distutils ha

Re: Python or PHP?

2005-04-23 Thread Tim Tyler
Mage <[EMAIL PROTECTED]> wrote or quoted: > check this: http://wiki.w4py.org/pythonvsphp.html Good - but it hardly mentions the issue of security - which seems like a bit of a problem for PHP at the moment. -- __ |im |yler http://timtyler.org/ [EMAIL PROTECTED] Remove lock to reply.

Re: Python licence again

2005-04-23 Thread Tim Tyler
fuzzylollipop <[EMAIL PROTECTED]> wrote or quoted: > try spelling license correctly next time and heading the google > suggestions that probably looked like "didn't you mean : Python License" How do you spell license correctly? -- __ |im |yler http://timtyler.org/ [EMAIL PROTECTED] R

Re: a=[ lambda t: t**n for n in range(4) ]

2005-04-23 Thread Bengt Richter
On 22 Apr 2005 20:45:55 -0700, "El Pitonero" <[EMAIL PROTECTED]> wrote: >Bengt Richter wrote: >> I still don't know what you are asking for, but here is a toy, >> ... >> But why not spend some time with the tutorials, so have a few more >cards in your deck >> before you try to play for real? ;-) >

Re: XML parsing per record

2005-04-23 Thread Kent Johnson
Willem Ligtenberg wrote: Is there an easy way, to couple data together. Because I have discoverd an irritating feature in the xml file. Sometimes this is a database reference: UCSC 1234 And sometimes: UCS

Re: Python or PHP?

2005-04-23 Thread Mage
Tim Tyler wrote: >Mage <[EMAIL PROTECTED]> wrote or quoted: > > > >>check this: http://wiki.w4py.org/pythonvsphp.html >> >> > >Good - but it hardly mentions the issue of security - which seems >like a bit of a problem for PHP at the moment. > > I don't think so. Bad programmers are able to

func_code vs. string problem

2005-04-23 Thread Filip Dreger
Each function has a func_code property that is suposed to contain the pure bytecode of the function. All the context (including reference to relevant namespaces) is stored in different fields of the function object. Since 'exec' is able to execute any string or bytecode in the current scope, it

Re: Python or PHP?

2005-04-23 Thread Kirk Job Sluder
"Lad" <[EMAIL PROTECTED]> writes: > Is anyone capable of providing Python advantages over PHP if there are > any? > Cheers, > L. PHP is strongly wedded to providing web-based content, while Python can be used to build a large number of different types of applications. -- Kirk Job-Sluder "The

Re: Trouble Installing TTX/FontTools (asks for .NET FrameworkPackages)

2005-04-23 Thread Fredrik Lundh
Jesper Olsen wrote: > > Apparently setup.py tries to compile a c file, which of course > doesn't > > work if there's no compiler. > > In fact it does not work even if there is a compiler - seems distutils > has been broken in python2.4 (it works in python2.3). distutils works just fine in 2.4. b

Re: How to run Python in Windows w/o popping a DOS box?

2005-04-23 Thread Bengt Richter
On 22 Apr 2005 21:16:04 -0700, [EMAIL PROTECTED] wrote: >>>I think of it like the ''.join semantics. The object knows best how >to >>>handle join (even if it looks wierd to some people). In the #! case, >>>the program knows best how to start itself. > >>This I don't understand ;-) > >With ','.joi

Re: Python or PHP?

2005-04-23 Thread Simon John
I've been a PHP and Perl programmer (amongst others) for 10 years or more now, and a Python coder for 3 or so. I have come to hate PHP now, it's pseudo-OOP is awful, it's dog slow at handling XML, it's so easy to use that most of the programmers I've had contact with are very sloppy and do things

Does numarray search for blas and lapack during installation?

2005-04-23 Thread Edward C. Jones
I have a PC with Debian sid installed. I install all my Python stuff in /usr/local. I just installed numarray 1.3.1. Blaslite and lapacklite were compiled. Did the installation process search for blas and lapack? -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Imaging Library and PyGTK - color image path?

2005-04-23 Thread Jeremy Bowers
On Sat, 23 Apr 2005 10:20:29 +0200, Fredrik Lundh wrote: > which discusses draw_rgb_image and friends, and says that "if you can > convert your PIL image to a pixel data string or buffer object, you could > use them to display the image". here's some code that seems to do exactly > that: > >

Re: Python or PHP?

2005-04-23 Thread Fredrik Lundh
"Mage" wrote: > I don't think so. Bad programmers are able to write bad programs in any > language. in PHP, good programmers are able to write bad programs without even noticing. (every successful server attack I've seen closely the last few years have been through PHP. it's totally without com

Re: PDF Printing support from Python

2005-04-23 Thread M.E.Farmer
> You're use of the word "driver" is one with which I'm not > familiar. But I don't really "do windows" so it's probably a > Widnowism. It is a windowism but not exclusively ;). http://www.collaborium.org/onsite/romania/UTILS/Printing-HOWTO/winprinters.html This is the first link I found that men

Re: Python or PHP?

2005-04-23 Thread Mage
Fredrik Lundh wrote: > >sql injection? what's your excuse for not using data binding? > > I am not sure I truly understand your question. So far my own servers didn't get successful sql injection attack. I just saw some on other sites and did one for demonstration. Avoid them is easy with set_

Re: Python or PHP?

2005-04-23 Thread Jeremy Bowers
On Sat, 23 Apr 2005 20:13:24 +0200, Mage wrote: > Avoid them is easy with set_type($value,"integer") for integer values and > correct escaping for strings. "Avoiding buffer overflows in C is easy, as long as you check the buffers each time." The *existence* of a technique to avoid problems is not

Re: Python or PHP?

2005-04-23 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2005-04-23 15:53:17 +0200: > Lad wrote: > > >Is anyone capable of providing Python advantages over PHP if there are > >any? > > I am also new to python but I use php for 4 years. I can tell: > > - python is more *pythonic* than php > - python has its own perfume > http://w

Re: python modules in home dir

2005-04-23 Thread Uche Ogbuji
On Sat, 2005-04-16 at 08:12 -0600, Uche Ogbuji wrote: > On Sat, 2005-04-09 at 14:09 -0700, dzieciou wrote: > > > I'm new-comer in Python. > > I want to install few Python modules (4Suite, RDFLib, Twisted and Racoon) > > in my home directory, since Python installation is already installed in the >

python and Tile Studio

2005-04-23 Thread André Roberge
Has anyone used Python with Tile Studio to create games? http://tilestudio.sourceforge.net/ André -- http://mail.python.org/mailman/listinfo/python-list

Re: XML file parsing with SAX

2005-04-23 Thread Uche Ogbuji
On Sat, 2005-04-23 at 15:20 +0200, Willem Ligtenberg wrote: > I decided to use SAX to parse my xml file. > But the parser crashes on: > File "/usr/lib/python2.3/site-packages/_xmlplus/sax/handler.py", line 38, > in fatalError > raise exception > xml.sax._exceptions.SAXParseException: NCBI_En

Handling lists

2005-04-23 Thread [EMAIL PROTECTED]
I have a question on python lists. Suppose I have a 2D list list = [[10,11,12,13,14,78,79,80,81,300,301,308]] how do I convert it so that I arrange them into bins . so If i hvae a set of consecutive numbers i would like to represent them as a range in the list with max and min val of the range alo

Using Ming on Windows

2005-04-23 Thread André Roberge
I tried to install Ming (http://sourceforge.net/projects/ming/) on Windows to use with Python *but* I can't [/don't know how to] use "make" to install it. Does anyone know where I could find a ready-made compiled version for Windows to just "put in" my site-packages directory. Any help would be app

Re: Handling lists

2005-04-23 Thread Mage
[EMAIL PROTECTED] wrote: >I have a question on python lists. >Suppose I have a 2D list >list = [[10,11,12,13,14,78,79,80,81,300,301,308]] >how do I convert it so that I arrange them into bins . >so If i hvae a set of consecutive numbers i would like to represent >them as a range in the list with

Re: Python or PHP?

2005-04-23 Thread F. Petitjean
Le Sat, 23 Apr 2005 19:11:19 +0200, Fredrik Lundh a écrit : > in PHP, good programmers are able to write bad programs without > even noticing. +1 QOTW --- The use of COBOL cripples the mind; its teaching should, therefore, be regarded as a criminal offense. Dr. E.W. Dijkstra -- http://mail.pyth

Re: Does numarray search for blas and lapack during installation?

2005-04-23 Thread RickMuller
IIRC, no. But the setup.py script is fairly easy to hack to link in your own blas/lapack libraries. -- http://mail.python.org/mailman/listinfo/python-list

Bounding box on clusters in a 2D list

2005-04-23 Thread [EMAIL PROTECTED]
If I have ex: x = [[1,1,1,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0], [1,1,1,0,1,1,0,0,0,0,0,1,1,1,1,0,0,0], [1,1,1,0,1,1,1,0,1,1,0,1,1,1,0,0,0,0], [0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0]] what I want is a boundingbox over the region where we find clusters of 1's.So for instance in th

Re: func_code vs. string problem

2005-04-23 Thread Filip Dreger
I came up with a simpler description of the problem. It's all in the simple source: # we define 'print b' in three different ways: as a string, # a bytecode and a function string="print b" code=compile(string,'string','exec') def function(): print b # now we make functions that test if it is

Re: XML file parsing with SAX

2005-04-23 Thread Willem Ligtenberg
I didn't make the XML file. And I don't like messing with other peoples data. So I just want my SAX parser to ignore it. I can't help if other people make it hard for me to read their xml file... On Sat, 23 Apr 2005 13:48:49 -0600, Uche Ogbuji wrote: > On Sat, 2005-04-23 at 15:20 +0200, Willem Li

Re: Handling lists

2005-04-23 Thread [EMAIL PROTECTED]
yes that makes sense.But the problem I am facing is if list= [300,301,303,305] I want to consider it as one cluster and include the range as [300,305] so this is where I am missing the ranges. so If the list has l = [300,301,302,308,401,402,403,408] i want to include it as [[300,308],[401,408]].

Re: func_code vs. string problem

2005-04-23 Thread Steven Bethard
Filip Dreger wrote: Each function has a func_code property that is suposed to contain the pure bytecode of the function. All the context (including reference to relevant namespaces) is stored in different fields of the function object. Since 'exec' is able to execute any string or bytecode in th

Re: func_code vs. string problem

2005-04-23 Thread Steven Bethard
Filip Dreger wrote: I am trying to find a way of executing functions without creating a nested scope, so they can share local and global namespace (even if they are declared in some other module). Why? Can you explain what the use case is? STeVe -- http://mail.python.org/mailman/listinfo/python-

Re: XML file parsing with SAX

2005-04-23 Thread Uche Ogbuji
On 4/23/05, Willem Ligtenberg <[EMAIL PROTECTED]> wrote: > so that will be sax.handler.feature_external_ges = "false" Yes. > And it will work? Honestly, I'm not sure. It should, but I've found these edge cases a bit hard to predict in the Python built-in libs :-( > But what about using a cata

Re: Using Ming on Windows

2005-04-23 Thread Jack Diederich
On Sat, Apr 23, 2005 at 05:13:29PM -0300, Andr? Roberge wrote: > I tried to install Ming > (http://sourceforge.net/projects/ming/) > on Windows to use with Python *but* > I can't [/don't know how to] use "make" to install it. > > Does anyone know where I could find a ready-made compiled > version

Re: memory profiler?

2005-04-23 Thread John Reese
On Wed, 20 Apr 2005 23:06:51 -0400, Peter Hansen <[EMAIL PROTECTED]> wrote: > John Reese wrote: >> Is there a memory or heap profiler for python programs? So that, for >> example, if a program was bloating over time I could see how many of >> each object there were and maybe even where the referen

Re: Handling lists

2005-04-23 Thread James Stroud
On Saturday 23 April 2005 12:50 pm, [EMAIL PROTECTED] wrote: > I have a question on python lists. > Suppose I have a 2D list > list = [[10,11,12,13,14,78,79,80,81,300,301,308]] > how do I convert it so that I arrange them into bins  . > so If i hvae a set of consecutive numbers i would like to repr

Re: func_code vs. string problem

2005-04-23 Thread Filip Dreger
Uzytkownik "Steven Bethard" <[EMAIL PROTECTED]> napisal w wiadomosci news:[EMAIL PROTECTED] > Filip Dreger wrote: >> I am trying to find a way of executing functions without creating a >> nested scope, so they can share local and global namespace (even if >> they are declared in some other modu

Re: Python or PHP?

2005-04-23 Thread Leif K-Brooks
Mage wrote: However one of the worst cases is the sql injection attack. And sql injections must be handled neither by php nor by python but by the programmer. But Python's DB-API (the standard way to connect to an SQL database from Python) makes escaping SQL strings automatic. You can do this: cu

Re: func_code vs. string problem

2005-04-23 Thread Steven Bethard
Filip Dreger wrote: If I had a magic function 'exec in current scope' I would implement it like this: class actor: def __init__(): self.roles=[] def act(): for i in self.roles: exec i in current scope then the roles would simply be functions defined in any importable file. For

Why is Python not supporting full derivation of built-in file class?

2005-04-23 Thread Pierre Rouleau
Greetings, I'm wondering why the >> operator does not use the write() method of a class derived from the built-in file class as in DerivedFile below. In the following example: - StringFile is just a file-like string accumulation class that can be used in place of a real file to accumulate string

Re: func_code vs. string problem

2005-04-23 Thread Filip Dreger
Uzytkownik "Steven Bethard" <[EMAIL PROTECTED]> napisal w wiadomosci news:[EMAIL PROTECTED] > See the documentation: > > http://docs.python.org/ref/dynamic-features.html > > """The eval(), execfile(), and input() functions and the exec > statement do not have access to the full environment for r

Re: func_code vs. string problem

2005-04-23 Thread Steven Bethard
Filip Dreger wrote: Uzytkownik "Steven Bethard" <[EMAIL PROTECTED]> napisal w wiadomosci news:[EMAIL PROTECTED] See the documentation: http://docs.python.org/ref/dynamic-features.html """The eval(), execfile(), and input() functions and the exec statement do not have access to the full environme

Re: Python or PHP?

2005-04-23 Thread Mike Meyer
"Simon John" <[EMAIL PROTECTED]> writes: > I still love Perl, it's a bit of an art form, as "there's more than one > way to do it", whereas Python usually only allows one way to do it, > which may or may not be a better mantra The Python mantra leads to 1) less programmer overhead, and 2) fas

Re: PDF Printing support from Python

2005-04-23 Thread Mike Meyer
Dennis Lee Bieber <[EMAIL PROTECTED]> writes: > On Fri, 22 Apr 2005 17:41:22 -0500, Mike Meyer <[EMAIL PROTECTED]> declaimed > the following in comp.lang.python: > >> No, you don't. My print system does that, and I don't have acrobat >> installed. I have ghostscript installed, which includes pdf2p

Re: Python or PHP?

2005-04-23 Thread Leif K-Brooks
John Bokma wrote: Not. Perl and Java use similar methods where one can specify place holders, and pass on the data unescaped. But still injection is possible. How? -- http://mail.python.org/mailman/listinfo/python-list

Re: PDF Printing support from Python

2005-04-23 Thread Grant Edwards
On 2005-04-23, Mike Meyer <[EMAIL PROTECTED]> wrote: >>> No, you don't. My print system does that, and I don't have >>> acrobat installed. I have ghostscript installed, which >>> includes pdf2ps - which handles this particular translation. >>> >> Okay, so you've converted one page layout lang

Re: Python or PHP?

2005-04-23 Thread Leif K-Brooks
John Bokma wrote: my $sort = $cgi->param( "sort" ); my $query = "SELECT * FROM table WHERE id=? ORDER BY $sort"; And the equivalent Python code: cursor.execute('SELECT * FROM table WHERE id=%%s ORDER BY %s' % sort, [some_id]) You're right, of course, about being *able* to write code with SQL inj

Re: Python or PHP?

2005-04-23 Thread Leif Biberg Kristensen
Leif K-Brooks skrev: > But Python's DB-API (the standard way to connect to an SQL database > from Python) makes escaping SQL strings automatic. You can do this: > > cursor.execute('UPDATE foo SET bar=%s WHERE id=%s', ["foo'bar", 123]) So. I've been writing SQL queries in Python like this, using

Re: Handling lists

2005-04-23 Thread Michael Spencer
[EMAIL PROTECTED] wrote: ... list = [[10,11,12,13,14,78,79,80,81,300,301,308]] how do I convert it so that I arrange them into bins . so If i hvae a set of consecutive numbers i would like to represent them as a range in the list with max and min val of the range alone. I shd get something like l

Re: Using Ming on Windows

2005-04-23 Thread Colin J. Williams
Jack Diederich wrote: On Sat, Apr 23, 2005 at 05:13:29PM -0300, Andr? Roberge wrote: I tried to install Ming (http://sourceforge.net/projects/ming/) on Windows to use with Python *but* I can't [/don't know how to] use "make" to install it. Does anyone know where I could find a ready-made compiled v

Re: Using Ming on Windows

2005-04-23 Thread André Roberge
Colin J. Williams wrote: Jack Diederich wrote: On Sat, Apr 23, 2005 at 05:13:29PM -0300, Andr? Roberge wrote: I tried to install Ming (http://sourceforge.net/projects/ming/) on Windows to use with Python *but* I can't [/don't know how to] use "make" to install it. I installed MinGW on a Windows XP

Re: Python or PHP?

2005-04-23 Thread Peter Ammon
Leif K-Brooks wrote: John Bokma wrote: my $sort = $cgi->param( "sort" ); my $query = "SELECT * FROM table WHERE id=? ORDER BY $sort"; And the equivalent Python code: cursor.execute('SELECT * FROM table WHERE id=%%s ORDER BY %s' % sort, [some_id]) You're right, of course, about being *able* to wr

Re: Bounding box on clusters in a 2D list

2005-04-23 Thread bearophileHUGS
I hope this is what you need, sometimes understanding the question is one of the hardest parts :-) If you can use a graph data structure, you can create a graph, and then you can find the lenght of all its connected components (indentations reduced to 2 spaces): . def mat2graph(g, m, good=None, w

Unicode problems, yet again

2005-04-23 Thread Ivan Voras
I have a string fetched from database, in iso8859-2, with 8bit characters, and I'm trying to send it over the network, via a socket: File "E:\Python24\lib\socket.py", line 249, in write data = str(data) # XXX Should really reject non-string non-buffers UnicodeEncodeError: 'ascii' codec can'

Re: Python or PHP?

2005-04-23 Thread Mike Meyer
John Bokma <[EMAIL PROTECTED]> writes: > Mike Meyer wrote: > >> "Simon John" <[EMAIL PROTECTED]> writes: >> >>> I still love Perl, it's a bit of an art form, as "there's more than >>> one way to do it", whereas Python usually only allows one way to do >>> it, which may or may not be a better mant

GUI woes

2005-04-23 Thread jeff elkins
Howdy, This may not belong here, if so apologies... I'm a python newbie, but have completed a console app that I'd like to run under X. Reading recent postings here, wxpython seemed a reasonable choice so under debian sid, I installed (via apt-get) the various wxpython stuff available.: libwx

Re: GUI woes

2005-04-23 Thread Kartic
The Great jeff elkins uttered these words on 4/23/2005 5:45 PM: test.py crashes with the error below. Any clues? === Running test.py: Traceback (most recent call last): File "./test.py", line 87, in ? app = MyApp(0) # Create an instance of the application class File "/usr/l

Re: Python or PHP?

2005-04-23 Thread Leif K-Brooks
Peter Ammon wrote: I'm bewildered why you haven't mentioned magic quotes. A one line change to the configuration file can render your PHP site almost entirely immune to SQL injection attacks. PHP's magic quotes is one of the most poorly-designed features I can think of. Instead of magically esc

Re: Unicode problems, yet again

2005-04-23 Thread Jp Calderone
On Sun, 24 Apr 2005 03:15:02 +0200, Ivan Voras <[EMAIL PROTECTED]> wrote: I have a string fetched from database, in iso8859-2, with 8bit characters, and I'm trying to send it over the network, via a socket: You don't have a string fetched from a database, in iso-8859-2, alas. That is the root o

help with binary file io, perhaps with generators?

2005-04-23 Thread Marcus Goldfish
I need to write a "fast" file reader in python for binary files structured as: … x[0] y[0] z[0] x[1] y[1] z[1] … where c[k] is the k-th element from sequence c. As mentioned, the file is binary -- spaces above are just for visualization. Each element, c[k], is a 16-bit int. I can assume I kno

Re: Unicode problems, yet again

2005-04-23 Thread Kent Johnson
Ivan Voras wrote: I have a string fetched from database, in iso8859-2, with 8bit characters, and I'm trying to send it over the network, via a socket: File "E:\Python24\lib\socket.py", line 249, in write data = str(data) # XXX Should really reject non-string non-buffers UnicodeEncodeError:

Variables

2005-04-23 Thread Richard Blackwood
To All: Folks, I need your help. I have a friend who claims that if I write: foo = 5 then foo is NOT a variable, necessarily. If you guys can define for me what a variable is and what qualifications you have to back you, I can pass this along to, hopefully, convince him that foo is indeed a va

Re: Variables

2005-04-23 Thread James Stroud
I think, strictly speaking, foo would be a "name" in python. >>> foo Traceback (most recent call last): File "", line 1, in ? NameError: name 'foo' is not defined On Saturday 23 April 2005 07:20 pm, so sayeth Richard Blackwood: > To All: > > Folks, I need your help. I have a friend who cl

  1   2   >