Re: Code formatting question: conditional expression

2009-08-25 Thread Ben Finney
"Nicola Larosa (tekNico)" writes: > Nicola Larosa wrote: > > Here's my take: > > > >     excessblk = Block(total - P.BASE, srccol, > > carry_button_suppress=True > >         ) if total > P.BASE else None > > Oops, it got shortened out: line longer than 72 chars, acceptable in > code, but not in e

Re: Object Reference question

2009-08-25 Thread Hendrik van Rooyen
On Tuesday 25 August 2009 21:32:09 Aahz wrote: > 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 >

Re: your favorite debugging tool?

2009-08-25 Thread Paul Rubin
Dennis Lee Bieber writes: > My normal debug technique is wolf fencing* (eg; print statements) That method was formerly completely automated on the web: http://www.st.cs.uni-saarland.de/askigor/faq.php It was amazing. Further info is here: http://www.st.cs.uni-saarland.de/dd/ -- htt

Re: Code formatting question: conditional expression

2009-08-25 Thread Nicola Larosa (tekNico)
Nicola Larosa wrote: > Here's my take: > >     excessblk = Block(total - P.BASE, srccol, > carry_button_suppress=True >         ) if total > P.BASE else None Oops, it got shortened out: line longer than 72 chars, acceptable in code, but not in email. I'll try again. If the first line is too long,

Re: Python on the Web

2009-08-25 Thread Graham Dumpleton
A few additional comments on top of what others have said. On Aug 26, 11:09 am, Phil wrote: > I've seen lots of web sites explaining everything, but for whatever > reason I seem to not be picking something up. > I am a graphical person, which is probably the reason I haven't found > my answer. >

PyObject_CallFunction and writable memory

2009-08-25 Thread Christopher Nebergall
I'm working a patch to a hex editor (frhed) written in c++ so it can load python scripts. Internally the c++ code has a unsigned char * of possibly serveral hundred megs which I want to send into the python code to modify.What is the best way to send the unsigned char * as writable memory into

Re: break unichr instead of fix ord?

2009-08-25 Thread Mark Tolonen
wrote in message news:2ad21a79-4a6c-42a7-8923-beb304bb5...@v20g2000yqm.googlegroups.com... 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'

Re: Division and right shift in python

2009-08-25 Thread Chris Rebert
On Tue, Aug 25, 2009 at 8:40 PM, Mark Tolonen wrote: > > "Cevahir Demirkiran" wrote in message > news:3f74e020908251648k7b391a09g78b155507b2f2...@mail.gmail.com... >> >> Hi, >> >> I would like to do a floor division by a power of 2 in python to make it >> faster than / (modular division in 2.x). >

Re: Python on the Web

2009-08-25 Thread Graham Dumpleton
On Aug 26, 1:17 pm, alex23 wrote: > Phil wrote: > > My interest in Python 3.1 was actually to develop a framework. Again, > > I can feel the flames. :) I understand there are enough frameworks but > > I actually have no applications that I wish to develop. > > No offense intended, but that's prob

Re: Division and right shift in python

2009-08-25 Thread Mark Tolonen
"Cevahir Demirkiran" wrote in message news:3f74e020908251648k7b391a09g78b155507b2f2...@mail.gmail.com... Hi, I would like to do a floor division by a power of 2 in python to make it faster than / (modular division in 2.x). However, it is slower. What is the reason of that? I checked them via:

Re: Python on the Web

2009-08-25 Thread Phil
On Aug 25, 11:17 pm, alex23 wrote: > Phil wrote: > > My interest in Python 3.1 was actually to develop a framework. Again, > > I can feel the flames. :) I understand there are enough frameworks but > > I actually have no applications that I wish to develop. > > No offense intended, but that's pro

Re: Python on the Web

2009-08-25 Thread alex23
Phil wrote: > My interest in Python 3.1 was actually to develop a framework. Again, > I can feel the flames. :) I understand there are enough frameworks but > I actually have no applications that I wish to develop. No offense intended, but that's probably the worst approach to take. Frameworks c

Re: web frameworks that support Python 3

2009-08-25 Thread Graham Dumpleton
On Aug 26, 12:19 pm, exar...@twistedmatrix.com wrote: > On 01:41 am, a...@pythoncraft.com wrote: > > > > > > >In article > >, > >Graham Dumpleton   wrote: > >>On Aug 24, 6:34=A0am, Sebastian Wiesner wrote: > > >>>In any case, there is bottle [1], which provides a *very minimal* > >>>framewo= > >>r

Re: Python on the Web

2009-08-25 Thread Phil
Thank you for the helpful and timely response. My interest in Python 3.1 was actually to develop a framework. Again, I can feel the flames. :) I understand there are enough frameworks but I actually have no applications that I wish to develop. I enjoy developing these kinds of things from scratch

Re: web frameworks that support Python 3

2009-08-25 Thread exarkun
On 01:41 am, a...@pythoncraft.com wrote: In article , Graham Dumpleton wrote: On Aug 24, 6:34=A0am, Sebastian Wiesner wrote: In any case, there is bottle [1], which provides a *very minimal* framewo= rk for WSGI web development. =A0Don't expect too much, it is really small, a= nd does

Re: Help with arrays

2009-08-25 Thread Dave Angel
Stephen Fairchild wrote: Philip Semanchuk wrote: On Aug 25, 2009, at 6:14 PM, Gleb Belov wrote: Hello! I'm working on an exercise wherein I have to write a Guess The Number game, but it's the computer who's guessing MY number. I can get it to work, but there's one obvious problem: t

Re: break unichr instead of fix ord?

2009-08-25 Thread Christian Heimes
Jan Kaliszewski wrote: Are you sure, you couldn't have UCS-4-compiled Python distro for Windows?? :-O Nope, Windows require UCS-2 builds. Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: Python on the Web

2009-08-25 Thread Robert Kern
On 2009-08-25 20:09 PM, Phil wrote: I've seen lots of web sites explaining everything, but for whatever reason I seem to not be picking something up. I am a graphical person, which is probably the reason I haven't found my answer. May somebody please confirm if my diagram accurately represents th

Re: web frameworks that support Python 3

2009-08-25 Thread Aahz
In article , Graham Dumpleton wrote: >On Aug 24, 6:34=A0am, Sebastian Wiesner wrote: >> >> In any case, there is bottle [1], which provides a *very minimal* framewo= >rk >> for WSGI web development. =A0Don't expect too much, it is really small, a= >nd >> doesn't do much more than routing and mi

Re: Need help with Python scoping rules

2009-08-25 Thread Dave Angel
Stephen Fairchild wrote: You are trying to run code in a class that does not exist yet. def Demo(): def fact(n): if n < 2: return 1 else: return n * fact(n - 1) return type("Demo", (object,), {"fact": staticmethod(fact), "_classvar": fact(5)}) De

Return value of multiprocessing manager registerred function

2009-08-25 Thread Terry
Hi, I'm using the multiprocessing.manager to run procedures remotely. It all worked fine except I hope to have a different return value type. The remote function calls always return a proxy, which when I need to get the value it need to connect to the manager again to fetch it. But I just need th

Re: can python make web applications?

2009-08-25 Thread alex23
Mark wrote: > On Sun, 23 Aug 2009 21:45:17 +0100, Goke Aruna wrote: > >http://www.openerp.com, all done is python. > > That does look impressive. Is that Django or Turbogears? Turbogears, according to the product's wikipedia page. -- http://mail.python.org/mailman/listinfo/python-list

Re: multiprocessing managers and socket connection.

2009-08-25 Thread Terry
On Aug 25, 10:14 pm, Chris wrote: > 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

Python on the Web

2009-08-25 Thread Phil
I've seen lots of web sites explaining everything, but for whatever reason I seem to not be picking something up. I am a graphical person, which is probably the reason I haven't found my answer. May somebody please confirm if my diagram accurately represents the stack, generally speaking. http://i

Re: break unichr instead of fix ord?

2009-08-25 Thread Jan Kaliszewski
25-08-2009 o 21:45:49 wrote: 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. [snip] On Python 2.6, unichr() was "fixed" (using the word loosely) so that it too now fails

Re: Need help with Python scoping rules

2009-08-25 Thread Stephen Fairchild
You are trying to run code in a class that does not exist yet. def Demo(): def fact(n): if n < 2: return 1 else: return n * fact(n - 1) return type("Demo", (object,), {"fact": staticmethod(fact), "_classvar": fact(5)}) Demo = Demo() d = Demo() pri

Re: Is it a bug?

2009-08-25 Thread Jan Kaliszewski
25-08-2009 o 22:51:14 Gleb Belov wrote: I have two questions: 1) Is it possible and if so, how do I access each individual element? Are there any indexes and what is the syntax? It's a 'Read-The-Friendly-Manual' question. (hint: library reference - Built-in Types - ...) -- Jan Kaliszewski (

Re: Need help with Python scoping rules

2009-08-25 Thread Jan Kaliszewski
25-08-2009 o 22:16:24 Stephen Hansen wrote: The OP's probably is that during the execution of the class body, the class doesn't exist... so the 'def fact' -can't- use Classname.fact to address itself explicitly, and within fact the locals don't contain a reference to the function itself, an

Re: Python, qt, and lgpl

2009-08-25 Thread sturlamolden
On 25 Aug, 21:45, Terry Reedy wrote: > Will be good news if realized. Good news for everyone except Riverbank. -- http://mail.python.org/mailman/listinfo/python-list

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:47 pm, Evan Driscoll wrote: > So here is my simplified version that only works for globals: So I think this works if (1) you only use changed_value in the same module as it's defined in (otherwise it picks up the globals from the module it's defined in, which is almost certainly not

Re: Help with arrays

2009-08-25 Thread Mart.
On Aug 25, 11:50 pm, Stephen Fairchild wrote: > Philip Semanchuk wrote: > > > On Aug 25, 2009, at 6:14 PM, Gleb Belov wrote: > > >> Hello! I'm working on an exercise wherein I have to write a Guess The > >> Number game, but it's the computer who's guessing MY number. I can get > >> it to work, but

Division and right shift in python

2009-08-25 Thread Cevahir Demirkıran
Hi, I would like to do a floor division by a power of 2 in python to make it faster than / (modular division in 2.x). However, it is slower. What is the reason of that? I checked them via: def f2(x,n): t1 = clock() r = x/pow(2,n) t2 = clock() print (t2-t1) print r t2 = cl

Re: mod_python: Permission denied

2009-08-25 Thread David
On Aug 25, 4:00 pm, David wrote: > Thanks Graham. Let me contact Admin. Hi Graham: you are right. it's fixed now. Thanks again. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python for professsional Windows GUI apps?

2009-08-25 Thread geekworking
If you are planning a database driven app, you should first settle on a DB server. Any real enterprise DB system will put all of the business logic in the database server. The choice of a front end should be secondary. Wikipedia's list of Python apps: http://en.wikipedia.org/wiki/List_of_Python_s

Re: mod_python: Permission denied

2009-08-25 Thread David
disclaimer: i did not write this code. i copied it and inserted into my cgi code. it is from http://webpython.codepoint.net/mod_python_publisher_big_file_upload. -- http://mail.python.org/mailman/listinfo/python-list

Re: Help with arrays

2009-08-25 Thread Stephen Fairchild
Philip Semanchuk wrote: > > On Aug 25, 2009, at 6:14 PM, Gleb Belov wrote: > >> Hello! I'm working on an exercise wherein I have to write a Guess The >> Number game, but it's the computer who's guessing MY number. I can get >> it to work, but there's one obvious problem: the computer generates >

Re: mod_python: Permission denied

2009-08-25 Thread David
A little more info: "Defrosting.rtf" is a file that I wanted to upload. This file was supposed to upload to folder '/var/www/keyword- query/files/'. My code runs in root. -- http://mail.python.org/mailman/listinfo/python-list

Re: mod_python: Permission denied

2009-08-25 Thread Graham Dumpleton
On Aug 26, 8:43 am, David wrote: > Hello, > > I googled online however I did not find a clue my question. So I post > it here. > > I created a mod_python CGI to upload a file and saves it in folder "/ > var/www/keyword-query/files/".  My code runs in root. > >      fileitem = req.form['file'] > >

Re: How does the file.seek() work ?

2009-08-25 Thread Graham Dumpleton
On Aug 25, 5:37 am, Tim Chase wrote: > > I want the file pointer set to 100 and overwrite everything from there > [snip] > > def application(environ, response): > >     query=os.path.join(os.path.dirname(__file__),'teemp') > >     range=environ.get('HTTP_RANGE','bytes=0-').replace > > ('by

mod_python: Permission denied

2009-08-25 Thread David
Hello, I googled online however I did not find a clue my question. So I post it here. I created a mod_python CGI to upload a file and saves it in folder "/ var/www/keyword-query/files/". My code runs in root. fileitem = req.form['file'] # Test if the file was uploaded if fileitem.fi

Re: best way to display photos

2009-08-25 Thread samwyse
On Aug 25, 1:40 am, Thomas Guettler wrote: > Some years ago I had the same problem. > > I wrote a simple app with pygtk. You get get it from here: >    http://guettli.sourceforge.net/gthumpy/src/README.html > The next pictures get loaded in background. Switching from > one image to the next is fas

Re: Python on Crays

2009-08-25 Thread Carrie Farberow
Ok, here are links to word documents outlining the commands I executed as well as the make.log file and the make_install.log file instructions/commands: https://mywebspace.wisc.edu/xythoswfs/webui/_xy-29018965_1-t_dSnfEm5b make.log: https://mywebspace.wisc.edu/xythoswfs/webui/_xy-29018966_1-t_zj

Re: Help with arrays

2009-08-25 Thread Philip Semanchuk
On Aug 25, 2009, at 6:14 PM, Gleb Belov wrote: Hello! I'm working on an exercise wherein I have to write a Guess The Number game, but it's the computer who's guessing MY number. I can get it to work, but there's one obvious problem: the computer generates random numbers until one of them corres

Help with arrays

2009-08-25 Thread Gleb Belov
Hello! I'm working on an exercise wherein I have to write a Guess The Number game, but it's the computer who's guessing MY number. I can get it to work, but there's one obvious problem: the computer generates random numbers until one of them corresponds to my number, but it will often generate one

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

2009-08-25 Thread MRAB
Ryniek90 wrote: Ryniek90 wrote: [snip] Here's my script code: *http://paste.ubuntu.com/259310/ *Shouldn't that bug be patched already :-? Are you giving it the contents of the file when it's actually expecting the filename? Of course the content of the file: [snip] See? *backup_obj.add

Re: conditional for-statement

2009-08-25 Thread Piet van Oostrum
> seb (s) wrote: >s> i am still a bit puzzle by the following. >s> I read in >http://en.wikipedia.org/wiki/Python_syntax_and_semantics#Generators >s> """Python 3.0 unifies all collection types by introducing dict and set >s> comprehensions, similar to list comprehensions: > [ n*n for

Re: Need help with Python scoping rules

2009-08-25 Thread John Posner
Stephen Hansen said: But http://docs.python.org/tutorial/classes.html says, in Section 9.3 "A First Look at Classes": When a class definition is entered, a new namespace is created, and used as the local scope — thus, all assignments to local variables go into this new name

Re: Python for professsional Windows GUI apps?

2009-08-25 Thread Peter Decker
On Tue, Aug 25, 2009 at 7:24 AM, Wolfgang Keller wrote: > The only framework that seems to be worth trying is Dabo. Unfortunately > there's little documentation, and that's mostly outdated. To be honest, that was my biggest concern when I tried Dabo. However, after as small a learning curve as o

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

2009-08-25 Thread James Harris
On 24 Aug, 03:49, Dennis Lee Bieber wrote: ... > > Here's another suggested number literal format. First, keep the > > familar 0x and 0b of C and others and to add 0t for octal. (T is the > >thirdletter of octal as X is thethirdletter of hex.) The numbers > > above would be > >         The thing

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

2009-08-25 Thread Ryniek90
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. W

Re: conditional for-statement

2009-08-25 Thread seb
On Aug 25, 10:46 pm, Falcolas wrote: > On Aug 25, 1:58 pm, seb wrote: > > > On Aug 25, 9:42 pm, Falcolas wrote: > > > On Aug 25, 11:25 am, seb wrote: > > > So, what part of the statement does the "if" statement belong to; > > > particularly a concern considering this is valid python: > > > > fo

Re: Is it a bug?

2009-08-25 Thread Gleb Belov
On Aug 26, 12:59 am, Stephen Fairchild wrote: > Gleb Belov wrote: > > Hey everyone! I'm quite new to Python and equally new to newsgroups in > > general, so apologies if this makes no sense. > > > Basically, I was just exploring Python "arrays" on my own, since I > > come from C++. What I did was:

Re: Is it a bug?

2009-08-25 Thread Stephen Fairchild
Gleb Belov wrote: > Hey everyone! I'm quite new to Python and equally new to newsgroups in > general, so apologies if this makes no sense. > > Basically, I was just exploring Python "arrays" on my own, since I > come from C++. What I did was: words = ["Hi!", "What's up?", "Bye!"] print

Is it a bug?

2009-08-25 Thread Gleb Belov
Hey everyone! I'm quite new to Python and equally new to newsgroups in general, so apologies if this makes no sense. Basically, I was just exploring Python "arrays" on my own, since I come from C++. What I did was: >>> words = ["Hi!", "What's up?", "Bye!"] >>> print words ['Hi!', "What's up?", 'By

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:25 pm, "Diez B. Roggisch" wrote: > Modifying locals isn't really allowed - it might stop working with > certain implementations of python. > > And to be honest - I don't really see a use-case for your whole > approache. Why don't you want to introduce a new name? Wow, this actually w

Re: conditional for-statement

2009-08-25 Thread Falcolas
On Aug 25, 1:58 pm, seb wrote: > On Aug 25, 9:42 pm, Falcolas wrote: > > On Aug 25, 11:25 am, seb wrote: > > So, what part of the statement does the "if" statement belong to; > > particularly a concern considering this is valid python: > > > for x in y if y else z: > >     body > > can this be d

Re: os.popen output different from native shell output

2009-08-25 Thread nickname
On Aug 25, 11:57 am, Thomas Guettler wrote: > 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 no

Re: your favorite debugging tool?

2009-08-25 Thread Esmail
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 :-) Note that it's only a sign,

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

2009-08-25 Thread Diez B. Roggisch
Evan Driscoll schrieb: 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 l

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

Re: Need help with Python scoping rules

2009-08-25 Thread Stephen Hansen
> > > But http://docs.python.org/tutorial/classes.html says, in Section 9.3 "A > First Look at Classes": > > When a class definition is entered, a new namespace is created, > and used as the local scope — thus, all assignments to local variables > go into this new namespace. In particular, function

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

2009-08-25 Thread travis+ml-python
On Fri, Aug 21, 2009 at 03:13:12PM -0500, tra...@subspacefield.org wrote: > Since the authors of the paper (Wagner et. al.) are proposing a new > set of APIs to make all of this clearer, I'm thinking that I will > create a module specifically for dropping permissions. I've created the module here:

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

2009-08-25 Thread Diez B. Roggisch
Evan Driscoll schrieb: (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 objec

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, 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: 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

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: 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

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: 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

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: 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... -

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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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 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: 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: 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: 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: 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: 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: 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: 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: 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 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 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 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: Web Services examples using "raw" xml?

2009-08-25 Thread John Gordon
In <4a936e84$0$31337$9b4e6...@newsspool4.arcor-online.net> 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

  1   2   >