Re: elementtree

2009-08-25 Thread Nadia Johnson
On Aug 24, 7:29 pm, Dave Angel wrote: > Stefan Behnel wrote: > > Hi, > > > elsa wrote: > > >> I know how to turn HTML into an ElementTree object > > > I don't. ;) > > > ElementTree doesn't have an HTML parser, so what do you use for parsing? > > >> but I don't know > >> how to then view the struct

Re: Python memory management <-> virtualized server environments

2009-08-25 Thread gravityzoo-dmo
On 24 aug, 20:35, "Martin P. Hellwig" wrote: > gravityzoo-dmo wrote: > > Hello everyone, > > > I was wondering if anyone here has had any experience in running > > Python in a virtualized server environment? > > The reason I'm asking is the recent thing I noticed when running my > > server applica

Re: Putting together a larger matrix from smaller matrices

2009-08-25 Thread Peter Otten
Matjaz Bezovnik wrote: > This is something which is done often in FEM methods, and the alike. > > I have matrix A of 3x3 elements, and B, of the same number of > elements, 3x3. > > What would be the most obvious way to assemble a matrix which: > a11 a12 a13 > a21 a22 a23 > a31 a32 a33+b11 b12 b1

Re: Python memory management <-> virtualized server environments

2009-08-25 Thread Martin P. Hellwig
gravityzoo-dmo wrote: On 24 aug, 20:35, "Martin P. Hellwig" wrote: gravityzoo-dmo wrote: Hello everyone, I was wondering if anyone here has had any experience in running Python in a virtualized server environment? The reason I'm asking is the recent thing I noticed when running my server appli

matplotlib / backend

2009-08-25 Thread Pierre
Hello, I'm to plot some results but it doesn't work. I got this error : /usr/local/libre_rep/python-2.6.1/RHEL_5__x86_64/lib/python2.6/site- packages/matplotlib/backends/__init__.py:41: UserWarning: Your currently selected backend, 'agg' does not support show(). Please select a GUI backend in you

Re: Numeric literals in other than base 10 - was Annoying octal notation

2009-08-25 Thread James Harris
On 25 Aug, 01:25, Steven D'Aprano wrote: > On Mon, 24 Aug 2009 16:23:06 -0700, James Harris wrote: > > Sure but while I wouldn't normally want to type something as obscure as > > 32"rst" into a file of data I might want to type 0xff00 or similar. That > > is far clearer than 65280 in some cases.

Re: Protecting against callbacks queuing up?

2009-08-25 Thread Hendrik van Rooyen
On Monday 24 August 2009 17:32:23 Esben von Buchwald wrote: > Hendrik van Rooyen wrote: 8< -- some stuff about an "after" call -- > > I'm new to python, what is an after function and an after call? Couldn't > find excact answer on google...? Do you have a link t

os.popen output different from native shell output

2009-08-25 Thread nickname
Hi all, I am a relative newbie to python, I am using os.popen to run an ls command. The output that I get using the read() function is different in look and feel from when I run the ls command natively from the shell (not via python). I display the ouput via python by using the print functio

Re: os.popen output different from native shell output

2009-08-25 Thread Chris Rebert
On Tue, Aug 25, 2009 at 1:36 AM, nickname wrote: > Hi all, >       I am a relative newbie to python, I am using os.popen to run an > ls command. The output that I get using the read() function is > different in look and feel from when I run the ls command natively > from the shell (not via python).

Re: Questions on XML

2009-08-25 Thread SUBHABRATA BANERJEE
I was trying this. Looks perfectly fine. There must be something really wrong. If you can reinstall Python 2.5. >>> a1=raw_input("String") Stringআম On Mon, Aug 24, 2009 at 12:18 AM, Rami Chowdhury wrote: > My problem is with IDLE on Windows. When I try to type Bangla directly into > the IDLE wind

Re: matplotlib / backend

2009-08-25 Thread baloan
On Aug 25, 10:12 am, Pierre wrote: > Hello, > > I'm to plot some results but it doesn't work. > I got this error : > > /usr/local/libre_rep/python-2.6.1/RHEL_5__x86_64/lib/python2.6/site- > packages/matplotlib/backends/__init__.py:41: UserWarning: > Your currently selected backend, 'agg' does not

Re: os.popen output different from native shell output

2009-08-25 Thread Thomas Guettler
hi, you get the popen output like this: u...@unixhost> ls | cat nickname schrieb: > Hi all, >I am a relative newbie to python, I am using os.popen to run an > ls command. The output that I get using the read() function is > different in look and feel from when I run the ls command nativ

Re: your favorite debugging tool?

2009-08-25 Thread Michele Simionato
On Aug 22, 4:25 pm, Esmail wrote: > Hi all, > > What is your favorite tool to help you debug your > code? The times when I would just use 'print' are long past. Nowadays I spend lots of my time with code written by others than myself. I use pdb all the time, and now also ipdb (ipdb is very cool i

Re: print() and unicode strings (python 3.1)

2009-08-25 Thread 7stud
On Aug 24, 10:09 pm, Ned Deily wrote: > In article > , > > > > 7stud wrote: > > On Aug 24, 2:41 pm, "Martin v. Löwis" wrote: > > > > I can't figure out a way to programatically set the encoding for > > > > sys.stdout. So where does that leave me? > > > > You should be setting the terminal enco

unexpected token `;'

2009-08-25 Thread bbarbero
Hello to all! I am struggling with a script in python for a while now, and decided to look for some help. I am running a code that takes commands from Marsyas(open source for Music analysis). #!/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6 #!/bin/bashimport math import re

Re: unexpected token `;'

2009-08-25 Thread mmelchert
[email protected] wrote: > Hello to all! > > I am struggling with a script in python for a while now, and decided > to look for some help. I am running a code that takes commands from > Marsyas(open source for Music analysis). > > #!/Library/Frameworks/Python.framework/Versions/2.6/bin/pyth

PyCon 2010 - Call for Tutorials

2009-08-25 Thread Greg Lindstrom
The period to submit proposals for PyCon 2010 in Atlanta, Georgia (USA) is now open and will close on October 18. Tutorials are 3-hour long classes on a specific Python technique, package or technology and are taught by members of the Python community. If you have knowledge in a particular topic

Re: unexpected token `;'

2009-08-25 Thread Diez B. Roggisch
[email protected] wrote: > Hello to all! > > I am struggling with a script in python for a while now, and decided > to look for some help. I am running a code that takes commands from > Marsyas(open source for Music analysis). > > #!/Library/Frameworks/Python.framework/Versions/2.6/bin/pyth

Re: Python for professsional Windows GUI apps?

2009-08-25 Thread Wolfgang Keller
> I need controls for business apps like access to databases, good data > grid, printing reports (with or without barcodes), etc. The area of _desktop_ database application development indeed looks like a vast and very hostile desert in the Python landscape. The only framework that seems to be w

Re: can python make web applications?

2009-08-25 Thread Mark
On Sun, 23 Aug 2009 21:45:17 +0100, Goke Aruna wrote: > A lot check this fantastic open source application, > http://www.openerp.com, all done is python. That does look impressive. Is that Django or Turbogears? -- Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: problem to write a THREAD enabled python extension

2009-08-25 Thread Andreas Otto
Stefan Behnel wrote: > > You forgot to create a thread state for the new thread. See the > PyThreadState_New() function. > this does not really solve the problem even if the original error does no happen anymore ... but a bucket of other error happen >>> sometimes <<< and this mean that time

Re: basic thread question

2009-08-25 Thread Piet van Oostrum
> sturlamolden (s) wrote: >s> On 25 Aug, 01:26, Piet van Oostrum wrote: >>> That's because it doesn't use copy-on-write. Thereby losing most of its >>> advantages. I don't know SUA, but I have vaguely heard about it. >s> SUA is a version of UNIX hidden inside Windows Vista and Windows 7 >s>

Re: web frameworks that support Python 3

2009-08-25 Thread Nobody
On Sun, 23 Aug 2009 16:32:09 -0400, Albert Hopkins wrote: > What's different about Python 3 is that there is only unicode strings, > whereas Python 2 has a string type and a unicode type. Python 2 has "str" (char) and "unicode" (wchar) types. Python 3 has "bytes" (char) and "str" (wchar) types.

Re: unexpected token `;'

2009-08-25 Thread Benjamin Kaplan
On Tue, Aug 25, 2009 at 7:25 AM, Diez B. Roggisch wrote: > > > Hello to all! > > > > I am struggling with a script in python for a while now, and decided > > to look for some help. I am running a code that takes commands from > > Marsyas(open source for Music analysis). > > > > #!/Library/Framewor

Re: sgmllib.py

2009-08-25 Thread Nobody
On Mon, 24 Aug 2009 09:08:07 +0200, Stefan Behnel wrote: > But note that sgmllib is a particularly cumbersome way to deal with HTML. Mostly because it only provides a tokeniser, not a parser. Whoever wrote it doesn't appear to understand the difference. -- http://mail.python.org/mailman/listinf

Re: unexpected token `;'

2009-08-25 Thread Peter Otten
[email protected] wrote: > I am struggling with a script in python for a while now, and decided > to look for some help. I am running a code that takes commands from > Marsyas(open source for Music analysis). > cmd = "sfplay " + colist[2] > print cmd > fileout = commands.getoutput(cmd) You

Re: your favorite debugging tool?

2009-08-25 Thread Esmail
Paul Rubin wrote: Esmail writes: What is your favorite tool to help you debug your code? I've been getting along with 'print' statements but that is getting old and somewhat cumbersome. Beyond print statements, I use pdb a lot. Winpdb (www.winpdb.org) is even better, but is kind of cumbersom

Re: your favorite debugging tool?

2009-08-25 Thread Esmail
Michele Simionato wrote: On Aug 22, 4:25 pm, Esmail wrote: Hi all, What is your favorite tool to help you debug your code? The times when I would just use 'print' are long past. Nowadays I spend lots of my time with code written by others than myself. I use pdb all the time, and now also ipd

Re: your favorite debugging tool?

2009-08-25 Thread Esmail
Robert Marshall wrote: On 24 Aug 2009, Paul Rubin wrote: Esmail writes: What is your favorite tool to help you debug your code? I've been getting along with 'print' statements but that is getting old and somewhat cumbersome. Beyond print statements, I use pdb a lot. Winpdb (www.winpdb.org)

Re: [ANN] pyxser-1.2r --- Python-Object to XML serialization module

2009-08-25 Thread Daniel Molina Wegener
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 Stefan Behnel on Tuesday 25 August 2009 01:23 wrote in comp.lang.python: > Stefan Behnel wrote: >> for all byte >> strings, regardless of their encoding (since you can't even know if they >> represent encoded text at all). > > Hmm, having written

Would there be work for a sysadmin who specializes in python?

2009-08-25 Thread walterbyrd
If I took the time to really learn to use python for sysadmin work, would I be able to find jobs, or even contract jobs? >From what I am seeing on the job boards etc., I would have to say no. It looks to me as though I could possibly do that with perl, but not python. Of course, I could be missin

Re: Temat:, Re: IOError: [Errno 22] invalid mode ('wb') or filename: in windows xp while making tarfile

2009-08-25 Thread ryniek
On 25 Sie, 07:33, Dennis Lee Bieber wrote: > On Mon, 24 Aug 2009 14:23:41 -0700 (PDT), ryniek > declaimed the following in gmane.comp.python.general: > > > C:\Users\Ryniek's WinSe7en\Documents\My Dropbox\Aplikacje > > \Moje_aplikacje\Pythonowe_aplikacje\Skrypty>python ba > > ckuper.py -f E:\APLIK

Re: print() and unicode strings (python 3.1)

2009-08-25 Thread Nobody
On Tue, 25 Aug 2009 03:41:54 -0700, 7stud wrote: > Why does echoing $LC_ALL or $LC_CTYPE just give me a blank string? Because the variables aren't set. The default locale for a particular category (e.g. LC_CTYPE) is taken from $LC_ALL if that is set, otherwise $LC_CTYPE, otherwise $LANG, otherwi

Re: Would there be work for a sysadmin who specializes in python?

2009-08-25 Thread Esmail
walterbyrd wrote: If I took the time to really learn to use python for sysadmin work, would I be able to find jobs, or even contract jobs? FWIW, I think one of the qualities of a good system admin would be the ability to work with a variety of tools and languages and not focus on one particula

Re: your favorite debugging tool?

2009-08-25 Thread Ben Finney
Esmail writes: > While I do believe in a minimalist approach (part of the reason I find > Python so appealing), using print statements sometimes only goes so > far (for me). Right, which is where the Python interactive interpreter (which I failed to mention in my initial response) comes in as my

Re: your favorite debugging tool?

2009-08-25 Thread Esmail
Hi Ben, Ben Finney wrote: Whenever a simple output statement is too cumbersome for debugging, I take it as a sign that the program is too cumbersome to follow. I'll have to think about this .. though my gut says this is true :-) re your other point about the interactive shell, I agree it's u

Re: proposal: add setresuid() system call to python

2009-08-25 Thread Hrvoje Niksic
[email protected] writes: > On Mon, Jul 20, 2009 at 04:10:35PM +0200, Hrvoje Niksic wrote: >> To emulate the os-module-type calls, it's better to raise exceptions >> than return negative values: >> >> > def setresuid(ruid, euid, suid): >> > return _setresuid(__uid_t(ruid), __

Re: os.popen output different from native shell output

2009-08-25 Thread Nobody
On Tue, 25 Aug 2009 01:36:08 -0700, nickname wrote: >I am a relative newbie to python, I am using os.popen to run an > ls command. The output that I get using the read() function is > different in look and feel from when I run the ls command natively > from the shell (not via python). As

Re: Protecting against callbacks queuing up?

2009-08-25 Thread Esben von Buchwald
Dennis Lee Bieber wrote: On Mon, 24 Aug 2009 17:32:23 +0200, Esben von Buchwald declaimed the following in gmane.comp.python.general: I'm new to python, what is an after function and an after call? Couldn't find excact answer on google...? Do you have a link to some docs? They would

Re: Items inheriting attributes from its container?

2009-08-25 Thread Kreso
Jan Kaliszewski wrote: [...] Great! Thanks to all of you for advices and code. K. -- http://mail.python.org/mailman/listinfo/python-list

Re: Would there be work for a sysadmin who specializes in python?

2009-08-25 Thread Brent Bloxam
walterbyrd wrote: If I took the time to really learn to use python for sysadmin work, would I be able to find jobs, or even contract jobs? From what I am seeing on the job boards etc., I would have to say no. It looks to me as though I could possibly do that with perl, but not python. Of cour

Re: csv module and None values

2009-08-25 Thread JKPeck
On Aug 24, 10:43 pm, John Yeung wrote: > On Aug 24, 5:00 pm, Peter Otten <[email protected]> wrote: > > > If I understand you correctly the csv.writer already does > > what you want: > > > >>> w.writerow([1,None,2]) > > 1,,2 > > > just sequential commas, but that is the special treatment. > > Witho

multiprocessing managers and socket connection.

2009-08-25 Thread Chris
I've been using multiprocessing managers and I really like the functionality. I have a question about reconnecting to a manager. I have a situation where I start on one machine (A) a manager that is listening and then on another machine (B) connects to that manager and uses its proxy object to cal

Re: Numeric literals in other than base 10 - was Annoying octal notation

2009-08-25 Thread Steven D'Aprano
On Mon, 24 Aug 2009 18:01:38 -0700, Mensanator wrote: >> If you want your data file to have values entered in hex, or oct, or >> even unary (1=one, 11=two, 111=three, =four...) you can. > > Unary? I think you'll find that Standard Positional Number Systems are > not defined for radix 1. Of c

Re: your favorite debugging tool?

2009-08-25 Thread Jean-Michel Pichavant
Esmail wrote: Hi Ben, Ben Finney wrote: Whenever a simple output statement is too cumbersome for debugging, I take it as a sign that the program is too cumbersome to follow. I'll have to think about this .. though my gut says this is true :-) That is not always true. When it comes to implem

TypeError: _getfullpathname() argument 1 must be (buffer overflow), not str in windows xp, while making tarfile

2009-08-25 Thread Ryniek90
Referring to my earlier posts: http://groups.google.pl/group/comp.lang.python/browse_thread/thread/4e34f995800f5352?hl=pl and http://groups.google.pl/group/comp.lang.python/browse_thread/thread/abf5573b8fceb37e?hl=pl# I've dealt with those errors. but now have another. When my backup scripts st

inconsistent sitecustomize.py importing...

2009-08-25 Thread Chris Withers
Hi All, Give this sitecustomize.py: print "ping" ...and this script: #!/usr/local/bin/python2.5 print "pong!" ...both in ~/folder, I would expect the output from: ~$./folder/script ...to be: ping pong ...but sitecustomize.py is not imported :-( If I do: ~$/usr/local/bin/python2.5 folder

Re: csv module and None values

2009-08-25 Thread Peter Otten
JKPeck wrote: > On Aug 24, 10:43 pm, John Yeung wrote: >> On Aug 24, 5:00 pm, Peter Otten <[email protected]> wrote: >> >> > If I understand you correctly the csv.writer already does >> > what you want: >> >> > >>> w.writerow([1,None,2]) >> > 1,,2 >> >> > just sequential commas, but that is the sp

Re: your favorite debugging tool?

2009-08-25 Thread Ben Finney
Esmail writes: > Hi Ben, > > Ben Finney wrote: > > > > Whenever a simple output statement is too cumbersome for debugging, I > > take it as a sign that the program is too cumbersome to follow. > > I'll have to think about this .. though my gut says this is true :-) Note that it's only a sign, *n

Even more inconsistent sitecustomize.py importing with PYTHONPATH rolled in...

2009-08-25 Thread Chris Withers
Chris Withers wrote: However, if I do: ~/folder$/usr/local/bin/python2.5 script ...sitecustomize.py IS imported! However, the following doesn't import sitecustomize.py: ~/folder$ ./script While the following DOES import sitecustomize.py: ~/folder$ export PYTHONPATH= ~/folder$ ./script Biz

Re: Even more inconsistent sitecustomize.py importing with PYTHONPATH rolled in...

2009-08-25 Thread Chris Withers
Chris Withers wrote: Bizarrely, none of the following import sitecustomize.py: ~$ export PYTHONPATH=~/folder ~$ ./script ~$ export PYTHONPATH=~/folder/ ~$ ./script ~$ export PYTHONPATH=~/folder ~/folder$ ./script ~$ export PYTHONPATH=~/folder/ ~/folder$ ./script Okay, brain fail on my part,

Re: Putting together a larger matrix from smaller matrices

2009-08-25 Thread Scott David Daniels
Matjaz Bezovnik wrote: If you are using numpy (which it sounds like you are): IDLE 2.6.2 >>> import numpy as np >>> v = np.array([[0,1,2],[3,4,5],[6,7,8]], dtype=float) >>> v array([[ 0., 1., 2.], [ 3., 4., 5.], [ 6., 7., 8.]]) >>> w = np.array([[10,11,12],[13,14,15],[16,17,1

Re: inconsistent sitecustomize.py importing...

2009-08-25 Thread Steven D'Aprano
On Tue, 25 Aug 2009 15:45:53 +0100, Chris Withers wrote: > Hi All, > > Give this sitecustomize.py: [...] > What gives?! Perhaps this? http://bugs.python.org/issue1734860 -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Need help with Python scoping rules

2009-08-25 Thread kj
I have many years of programming experience, and a few languages, under my belt, but still Python scoping rules remain mysterious to me. (In fact, Python's scoping behavior is the main reason I gave up several earlier attempts to learn Python.) Here's a toy example illustrating what I mean. I

Re: Putting together a larger matrix from smaller matrices

2009-08-25 Thread Matjaz Bezovnik
On Tue, 25 Aug 2009 08:26:44 -0700, Scott David Daniels wrote: >Matjaz Bezovnik wrote: > >If you are using numpy (which it sounds like you are): > >IDLE 2.6.2 > >>> import numpy as np > >>> v = np.array([[0,1,2],[3,4,5],[6,7,8]], dtype=float) > >>> v >array([[ 0., 1., 2.], >[ 3., 4.,

Re: Graph library recommendations for large graphs

2009-08-25 Thread Neal Becker
VanL wrote: > I am working on a project that will require building and querying large > graph objects (initially 8M nodes, 30-40M edges; eventually 40M nodes, > 100M edges). NetworkX seems to be the most popular, but I am concerned > that a dict representation for nodes would use too much memory -

Re: TypeError: _getfullpathname() argument 1 must be (buffer overflow), not str in windows xp, while making tarfile

2009-08-25 Thread MRAB
Ryniek90 wrote: Referring to my earlier posts: http://groups.google.pl/group/comp.lang.python/browse_thread/thread/4e34f995800f5352?hl=pl and http://groups.google.pl/group/comp.lang.python/browse_thread/thread/abf5573b8fceb37e?hl=pl# I've dealt with those errors. but now have another. Wh

Re: Protecting against callbacks queuing up?

2009-08-25 Thread Hendrik van Rooyen
On Tuesday 25 August 2009 15:21:16 Esben von Buchwald wrote: > Dennis Lee Bieber wrote: > > On Mon, 24 Aug 2009 17:32:23 +0200, Esben von Buchwald > > declaimed the following in > > > > gmane.comp.python.general: > >> I'm new to python, what is an after function and an after call? Couldn't > >> fi

Re: Code formatting question: conditional expression

2009-08-25 Thread Nicola Larosa (tekNico)
John Posner wrote: > Is there any consensus on how to format a conditional expression > that is too long for one line? Here's my take: excessblk = Block(total - P.BASE, srccol, carry_button_suppress=True ) if total > P.BASE else None -- Nicola Larosa - http://www.tekNico.net/ Nobody

Re: Need help with Python scoping rules

2009-08-25 Thread Martin P. Hellwig
kj wrote: Here's a toy example illustrating what I mean. It's a simplification of a real-life coding situation, in which I need to initialize a "private" class variable by using a recursive helper function. eh? class Demo(object): def fact(n): if n < 2: return 1

Re: your favorite debugging tool?

2009-08-25 Thread Falcolas
On Aug 23, 1:21 am, Hendrik van Rooyen wrote: > On Saturday 22 August 2009 16:49:22 Aahz wrote: > > > In article , > > > Esmail   wrote: > > >What is your favorite tool to help you debug your code? I've been > > >getting along with 'print' statements but that is getting old and > > >somewhat cumbe

Re: Need help with Python scoping rules

2009-08-25 Thread Diez B. Roggisch
kj wrote: > > > > I have many years of programming experience, and a few languages, > under my belt, but still Python scoping rules remain mysterious to > me. (In fact, Python's scoping behavior is the main reason I gave > up several earlier attempts to learn Python.) > > Here's a toy example

Re: Web Services examples using "raw" xml?

2009-08-25 Thread John Gordon
In <[email protected]> Stefan Behnel writes: > > I tried WSDL.Proxy() from the SOAPpy package and eventually end up > > with this error: > > > > xml.parsers.expat.ExpatError: not well-formed (invalid token): line 1, > > column 6 > Is that while parsing the

Re: Need help with Python scoping rules

2009-08-25 Thread Jean-Michel Pichavant
kj wrote: I have many years of programming experience, and a few languages, under my belt, but still Python scoping rules remain mysterious to me. (In fact, Python's scoping behavior is the main reason I gave up several earlier attempts to learn Python.) Here's a toy example illustrating what

Re: Need help with Python scoping rules

2009-08-25 Thread Jean-Michel Pichavant
Diez B. Roggisch wrote Classes are not scopes. Too bad, could have been handy. JM -- http://mail.python.org/mailman/listinfo/python-list

Re: Need help with Python scoping rules

2009-08-25 Thread Xavier Ho
I'm not really quite sure what voodoo I did here, but my code seems to work in Python 3.1.1 in the following way: class Demo(object): def func(self, n): return n * 5 _f = func(None, 5) d = Demo() print(d._f) print(d.func(5)) # OUTPUT 25 25 So, hmm? Regards, Ching-Yun "Xavier"

Re: Need help with Python scoping rules

2009-08-25 Thread Xavier Ho
On Wed, Aug 26, 2009 at 2:14 AM, Diez B. Roggisch wrote: > > Classes are not scopes. > > So the above doesn't work because name resolution inside functions/methods > looks for local variables first, then for the *global* scope. There is no > class-scope-lookup. Sorry, I'm coming here with sincer

Re: Need help with Python scoping rules

2009-08-25 Thread Diez B. Roggisch
Jean-Michel Pichavant wrote: > Diez B. Roggisch wrote >> Classes are not scopes. >> >> > Too bad, could have been handy. Nope. Because then a lot of people would write something like this: class Foo(object): def bar(self): bar() # note the missing self. And this would lead to e

Re: conditional for-statement

2009-08-25 Thread seb
On Aug 23, 11:02 pm, Chris Rebert wrote: > On Sun, Aug 23, 2009 at 1:36 PM, seb wrote: > > On Aug 23, 6:18 pm, John Posner wrote: > >> >> Hi, > > >> >> i was wondering if there is a syntax alike: > > >> >> for i in range(10) if i > 5: > >> >>     print i > > >> > You can write > > >> > for i in f

Re: conditional for-statement

2009-08-25 Thread seb
On Aug 24, 12:05 am, Mel wrote: > seb wrote: > > On Aug 23, 6:18 pm, John Posner wrote: > [ ... ] > >> How about using a generator expression instead of a list? > > >> for i in (x for x in range(10) if x > 5): > >> print i > > >> -John > > > Indeed, but we could have the same syntax than for gene

Re: Web Services examples using "raw" xml?

2009-08-25 Thread Stefan Behnel
John Gordon wrote: > Any suggestions? Well, yes, see the link I posted. http://effbot.org/zone/element-soap.htm That might actually be the easiest way to get your stuff done, and it avoids external dependencies (well, except for ElementTree, if you continue to use Python <= 2.4). Stefan -- htt

Re: Need help with Python scoping rules

2009-08-25 Thread John Posner
Diez said: Classes are not scopes. So the above doesn't work because name resolution inside functions/methods looks for local variables first, then for the *global* scope. There is no class-scope-lookup. But http://docs.python.org/tutorial/classes.html says, in Section 9.3 "A First Look at

Re: conditional for-statement

2009-08-25 Thread Rami Chowdhury
We could as consistenly explain that the syntax for n in range(10) if n%3==0: body means for n in range(10): if n%3==0: body This syntax has also the benefit of avoiding an extra level of indentation (the one for the if) that bears no real meaning on a structural level. I'm sorry, I

Re: basic thread question

2009-08-25 Thread sturlamolden
On 25 Aug, 13:33, Piet van Oostrum wrote: > I have heard about that also, but is there a Python implementation that > uses this? (Just curious, I am not using Windows.) On Windows we have three different versions of Python 2.6: * Python 2.6 for Win32/64 (from python.org) does not have os.fork.

Re: Python for professsional Windows GUI apps?

2009-08-25 Thread Gilles Ganault
On Tue, 25 Aug 2009 13:24:39 +0200, Wolfgang Keller wrote: >The area of _desktop_ database application development indeed looks like a >vast and very hostile desert in the Python landscape. > >The only framework that seems to be worth trying is Dabo. Unfortunately >there's little documentation,

Re: Need help with Python scoping rules

2009-08-25 Thread 7stud
On Aug 25, 12:11 pm, John Posner wrote: > Diez said: > > > > > Classes are not scopes. > > > So the above doesn't work because name resolution inside functions/methods > > looks for local variables first, then for the *global* scope. There is no > > class-scope-lookup. > > Buthttp://docs.python.or

Re: Python for professsional Windows GUI apps?

2009-08-25 Thread David Boddie
On Tuesday 25 August 2009 13:24, Wolfgang Keller wrote: > The area of _desktop_ database application development indeed looks like a > vast and very hostile desert in the Python landscape. > > The only framework that seems to be worth trying is Dabo. Unfortunately > there's little documentation,

Re: Putting together a larger matrix from smaller matrices

2009-08-25 Thread sturlamolden
On 25 Aug, 17:37, Matjaz Bezovnik wrote: > Scott, thank you very much for the snippet. > > It is exactly what I looked for; simple to read and obvious as to what > it does even a month later to a non-pythonist! Since you were talking about matrices, observe that numpy has a matrix subclass of n

Re: Putting together a larger matrix from smaller matrices

2009-08-25 Thread Robert Kern
On 2009-08-24 21:30 PM, Matjaz Bezovnik wrote: Dear all, I'm but a layman so do not take offence at this maybe over simple question. This is something which is done often in FEM methods, and the alike. I have matrix A of 3x3 elements, and B, of the same number of elements, 3x3. What would be

Re: os.popen output different from native shell output

2009-08-25 Thread nickname
On Aug 25, 6:16 am, Nobody wrote: > On Tue, 25 Aug 2009 01:36:08 -0700, nickname wrote: > >        I am a relative newbie to python, I am using os.popen to run an > > ls command. The output that I get using the read() function is > > different in look and feel from when I run the ls command native

Re: Python for professsional Windows GUI apps?

2009-08-25 Thread sturlamolden
On 25 Aug, 20:30, Gilles Ganault wrote: > Combined with the comment above about issues with printing, it looks > like Python for GUI apps isn't a very good idea :-/ With pywin32, printing is the same as for any other Windows app (you get MFC for Python). -- http://mail.python.org/mailman/listi

Re: Numeric literals in other than base 10 - was Annoying octal notation

2009-08-25 Thread Mensanator
On Aug 25, 9:14 am, Steven D'Aprano wrote: > On Mon, 24 Aug 2009 18:01:38 -0700, Mensanator wrote: > >> If you want your data file to have values entered in hex, or oct, or > >> even unary (1=one, 11=two, 111=three, =four...) you can. > > > Unary? I think you'll find that Standard Positional N

Re: your favorite debugging tool?

2009-08-25 Thread Robert Kern
On 2009-08-25 09:49 AM, Ben Finney wrote: Esmail writes: Hi Ben, Ben Finney wrote: Whenever a simple output statement is too cumbersome for debugging, I take it as a sign that the program is too cumbersome to follow. I'll have to think about this .. though my gut says this is true :-) N

Re: Python for professsional Windows GUI apps?

2009-08-25 Thread sturlamolden
On 25 Aug, 13:24, Wolfgang Keller wrote: > The area of _desktop_ database application development indeed looks like a > vast and very hostile desert in the Python landscape. Yes, you don't have drag-and-drop database tools like MS Access or FoxPro. You actually have to use a database API (such

Re: proposal: add setresuid() system call to python

2009-08-25 Thread travis
On Tue, Aug 25, 2009 at 03:03:12PM +0200, Hrvoje Niksic wrote: > You should use ctypes.get_errno() instead of os.errno; sorry about that. > > Also, when raising OSError, you should set the 'errno' attribute to the > appropriate code. How does that compare to: raise pythonapi.PyErr_SetFromErrno(p

Re: Waiting for a subprocess to exit

2009-08-25 Thread Aahz
In article , Miles Kaufmann wrote: > >debacle[1]). Leaving shell=3DFalse makes scripts more secure and =20 >robust; besides, when I'm putting together a command and its =20 >arguments, it's as convenient to build a list (['mycmd', 'myarg']) as =20= > >it is a string (if not more so). unless

Re: Simple IRC library

2009-08-25 Thread jason
On 2009-08-24 01:39:21 -0600, devaru said: Hi all, I am new to Python language. I want to capture(either in database or a file) the conversation in IRC. Fed. Please suggest me some simple IRC library or code snippet for this. I have used the oyoyo library with success. It's pretty nice an

Re: Need help with Python scoping rules

2009-08-25 Thread John Posner
7stud said: python ignores the names inside a function when it creates the function. This "program" will not produce an error: def f(): print x python parses the file and creates the function object and assigns the function object to the variable f. It's not until you execute the functio

Re: Object Reference question

2009-08-25 Thread Aahz
In article , Hendrik van Rooyen wrote: >On Friday 21 August 2009 08:07:18 josef wrote: >> >> My main focus of this post is: "How do I find and use object reference >> memory locations?" > a = [1,2,3,4] id(a) >8347088 Of course, that doesn't actually allow you to do anything... -

Context manager to temporarily change the variable of a register [aka write swap(a,b)]

2009-08-25 Thread Evan Driscoll
(If you don't want to read the following, note that you can answer my question by writing a swap function.) I want to make a context manager that will temporarily change the value of a variable within the scope of a 'with' that uses it. This is inspired by a C++ RAII object I've used in a few proj

Re: your favorite debugging tool?

2009-08-25 Thread Robert Kern
On 2009-08-25 06:57 AM, Esmail wrote: Michele Simionato wrote: On Aug 22, 4:25 pm, Esmail wrote: Hi all, What is your favorite tool to help you debug your code? The times when I would just use 'print' are long past. Nowadays I spend lots of my time with code written by others than myself. I

Re: os.popen output different from native shell output

2009-08-25 Thread Thomas Guettler
In one of the first chapters of "Advanced programming in the unix environment (second edition)" there is explained how a unix shell works. You could write you own shell using python. This way the python interpreter gets stared only once, and not for every call to "ls". Have fun, Thomas nickn

Re: conditional for-statement

2009-08-25 Thread Falcolas
On Aug 25, 11:25 am, seb wrote: > We could as consistenly explain that the syntax > > for n in range(10) if n%3==0: >   body > > means > > for n in range(10): >   if n%3==0: >     body > > This syntax has also the benefit of avoiding an extra level of > indentation (the one for the if) that bears

Python, qt, and lgpl

2009-08-25 Thread Terry Reedy
" New LGPL Python bindings for Qt slither into the light A new set of LGPL-licensed Python bindings for Qt has been announced. The project, which is backed by Nokia, will make it easier for commercial software developers to adopt Python and Qt for rapid application development." http://arste

Re: Context manager to temporarily change the variable of a register [aka write swap(a,b)]

2009-08-25 Thread Emile van Sebille
On 8/25/2009 12:33 PM Evan Driscoll said... So my question is: is what I want possible to do in Python? Probably not with immutables (as in your example) -- maybe otherwise. Emile -- http://mail.python.org/mailman/listinfo/python-list

break unichr instead of fix ord?

2009-08-25 Thread rurpy
In Python 2.5 on Windows I could do [*1]: # Create a unicode character outside of the BMP. >>> a = u'\U00010040' # On Windows it is represented as a surogate pair. >>> len(a) 2 >>> a[0],a[1] (u'\ud800', u'\udc40') # Create the same character with the unichr() function. >>> a =

Re: conditional for-statement

2009-08-25 Thread seb
On Aug 25, 9:42 pm, Falcolas wrote: > On Aug 25, 11:25 am, seb wrote: > > > > > We could as consistenly explain that the syntax > > > for n in range(10) if n%3==0: > >   body > > > means > > > for n in range(10): > >   if n%3==0: > >     body > > > This syntax has also the benefit of avoiding an

Re: Context manager to temporarily change the variable of a register [aka write swap(a,b)]

2009-08-25 Thread Evan Driscoll
On Aug 25, 2:33 pm, Evan Driscoll wrote: > I want to make a context manager that will temporarily change the > value of a variable within the scope of a 'with' that uses it. This is > inspired by a C++ RAII object I've used in a few projects. Ideally, > what I want is something like the following:

Re: Need help with Python scoping rules

2009-08-25 Thread Diez B. Roggisch
John Posner schrieb: Diez said: Classes are not scopes. So the above doesn't work because name resolution inside functions/methods looks for local variables first, then for the *global* scope. There is no class-scope-lookup. But http://docs.python.org/tutorial/classes.html says, in Section

Re: Context manager to temporarily change the variable of a register [aka write swap(a,b)]

2009-08-25 Thread Evan Driscoll
On Aug 25, 3:07 pm, Evan Driscoll wrote: > Okay, so I think I actually got this with some consultation with a > friend. Critiques? This is wrong; it's not quite working right. It does with the example I posted, but not in a more thorough test. I'm still ignoring the "you can't do this" answers f

  1   2   >