Re: "/a" is not "/a" ?

2009-03-06 Thread Steven D'Aprano
Paul Rubin wrote: > Steven D'Aprano writes: >> It is never >> correct to avoid using "is" when you need to compare for identity. > > When is it ever necessary to compare for identity? Is that a trick question? The obvious answer is, any time you need to. The standard library has dozens of test

Re: "/a" is not "/a" ?

2009-03-06 Thread alex23
On Mar 7, 10:57 am, s...@pobox.com wrote: > Right.  Again though, when newcomers conflate the concepts they can deceive > themselves into thinking "is" is just a faster "==". But _you_ only _just_ stated "It does have some (generally small) performance ramifications as well" and provided timing ex

Re: "/a" is not "/a" ?

2009-03-06 Thread Steven D'Aprano
s...@pobox.com wrote: > Steven> Mutable versus immutable is irrelevant. The complexity of the > Steven> object is irrelevant. The phase of the moon is irrelevant. The > Steven> *only* relevant factor is the programmer's intention: > > Which for a new user not familiar with the differi

Re: Should I use stackless python or threads?

2009-03-06 Thread alex23
On Mar 7, 9:35 am, Minesh Patel wrote: > I need to monitor each directory for the latest install, take it and > go perform some tests on a specific machine. I would like these > testing tasks to run concurrently for the obvious reasons. There are two other options to consider: * greenlet, which

Re: Help cleaning up some code

2009-03-06 Thread Paul Rubin
"andrew cooke" writes: > def copy(src, dst, name, quote_none=False): > value = src[name] > dst[name] = 'None' if quote_none and value is None else value def copy(src, dst, name, default=None): value = src[name] dst[name] = value if value is not None else default > copy(row, ad, name,

Re: Help cleaning up some code

2009-03-06 Thread oscar deits
Thanks a lot! that copy function is a really neat trick! Yes the ni's are sorted, and yes the query SHOULD be the one to limit it to just one set of ni's; however, i am having trouble implementing that in sql. I am using sqlite3 atm and right now i have a very large select statment the gets me wha

Re: Help cleaning up some code

2009-03-06 Thread andrew cooke
odeits wrote: > I am looking to clean up this code... any help is much appreciated. > Note: It works just fine, I just think it could be done cleaner. > > The result is a stack of dictionaries. the query returns up to > STACK_SIZE ads for a user. The check which i think is very ugly is > putting an

Re: how to prevent python import from looking into the current directory

2009-03-06 Thread Carl Banks
On Mar 6, 1:54 am, Ben Finney wrote: > (Could you please set a valid email address for people to contact you > if necessary?) > > TP writes: > > I would like to prevent the loading of modules in the current > > directory. > > You will, I think, like the new distinction between “absolute” and > “r

Re: wxPython fast and slow

2009-03-06 Thread Lie Ryan
iu2 wrote: Do you have any idea of what is going wrong? I think this might be related to the OS's process prioritization, focused Windows would get more priority than background window. -- http://mail.python.org/mailman/listinfo/python-list

Re: create boolean

2009-03-06 Thread Grant Edwards
On 2009-03-07, Rhodri James wrote: > On Fri, 06 Mar 2009 15:34:08 -, Grant Edwards wrote: > >> On 2009-03-06, Fencer wrote: >> >>> Hi, I need a boolean b to be true if the variable n is not >>> None and not an empty list, otherwise b should be false. >> >>> I ended up with: >> >>> b = n is n

Re: python image - ignore values in resize

2009-03-06 Thread Lie Ryan
Travis Kirstine wrote: I have be attempting to resize (downsample) a RGB image using the python image library resize function. Everything works fine but I would like to exclude black values 0,0,0 from the calculations. I have tried creating a alpha mask based on black values then performing the

Re: Should I use stackless python or threads?

2009-03-06 Thread Lie Ryan
Minesh Patel wrote: On Fri, Mar 6, 2009 at 3:16 PM, Jean-Paul Calderone wrote: On Fri, 6 Mar 2009 14:50:51 -0800, Minesh Patel wrote: I am trying to figure out the best approach to solve this problem: I want to poll various directories(can be run in the main thread). Once I notice a file has

Help cleaning up some code

2009-03-06 Thread odeits
I am looking to clean up this code... any help is much appreciated. Note: It works just fine, I just think it could be done cleaner. The result is a stack of dictionaries. the query returns up to STACK_SIZE ads for a user. The check which i think is very ugly is putting another contraint saying th

Re: where is the PyString_AsString in Python 3.0?

2009-03-06 Thread Benjamin Peterson
BigHand gmail.com> writes: > > Finally I got the results now. This did take me 10 hours to solve > this. the docs of 3.0.. > I hope this could help someone else: > const char *strExcType = PyBytes_AS_STRING(pyStr); > Py_XDECREF(str_exc_type); > Py_XDECREF(pyStr); You can't Py_DECREF() pySt

Re: retrieve traceback in embedded python of Python3.0?

2009-03-06 Thread BigHand
On Mar 7, 11:40 am, BigHand wrote: > Guys: > I have a embedded python in MFC app. to execute a py script of a.py, > the is only one line in a.py, it "a()" , normally ,excute this script > file ,you will get a >  "the exception type is " > "The exception value is name 'a' is not defined " > > Pytho

Re: retrieve traceback in embedded python of Python3.0?

2009-03-06 Thread BigHand
On Mar 7, 11:40 am, BigHand wrote: > Guys: > I have a embedded python in MFC app. to execute a py script of a.py, > the is only one line in a.py, it "a()" , normally ,excute this script > file ,you will get a >  "the exception type is " > "The exception value is name 'a' is not defined " > > Pytho

retrieve traceback in embedded python of Python3.0?

2009-03-06 Thread BigHand
Guys: I have a embedded python in MFC app. to execute a py script of a.py, the is only one line in a.py, it "a()" , normally ,excute this script file ,you will get a "the exception type is " "The exception value is name 'a' is not defined " Python3.0 with VS2005. here is the brief code: Py_Initi

Re: Threading and tkinter

2009-03-06 Thread gert
On Mar 6, 7:42 pm, a...@pythoncraft.com (Aahz) wrote: > [posted and e-mailed -- please reply to the group] > > In article > <492d5db9-3681-4ae8-827e-f2a4f66be...@v39g2000yqm.googlegroups.com>, > > gert   wrote: > > >After reading the docs and seeing a few examples i think this should > >work ? > >

Re: ANN: Dao, the official 1.0 version is released

2009-03-06 Thread Daniel Fetchinson
>> Why this hostility? The guy has worked on an interesting piece of >> software and tries to promote it to people who are most probably >> interested in programming languages. What's wrong with that? > > Because there's no particular reason for it to be in a Python-specific > forum. Yes there is,

Re: ANN: Dao, the official 1.0 version is released

2009-03-06 Thread Daniel Fetchinson
This is to announce the first official release of Dao. Dao is a simple yet powerful object-oriented programming language >>> So, you pimp your language in news groups for other languages? I see >>> your off topic post in 3 language groups I frequent, that's not the way >>> to get in

Re: where is the PyString_AsString in Python 3.0?

2009-03-06 Thread BigHand
On Mar 7, 9:34 am, BigHand wrote: > On Mar 7, 3:50 am, Benjamin Peterson wrote: > > > BigHand gmail.com> writes: > > > > > There is no PyString_AsString. Everything > > >> string is unicode now. (PyUnicode API) > > > hello,Ben, > > > could you give me an example? I almost know the > > > PyUnicod

Re: Is there a better way of doing this?

2009-03-06 Thread Paul Rubin
"Gabriel Genellina" writes: > > for x in population: > > f = fitness(x) > > fap += [(f, x)] > > total += f > > return sorted(fap, reverse=True), total > ... > Environmentally friendly Pythoneers avoid using discardable > intermediate envelopes: > > fap.a

Re: Is there a better way of doing this?

2009-03-06 Thread Gabriel Genellina
En Fri, 06 Mar 2009 21:31:01 -0200, mattia escribió: Thanks, I've found another solution here: http://www.obitko.com/tutorials/ genetic-algorithms/selection.php so here is my implementation: def get_fap(fitness, population): fap = [] total = 0 for x in population: f = fi

image exclude values from resize

2009-03-06 Thread T Kirstine
I've been downsampling RGB images using pil, but know I would like to exclude black 0,0,0 values from the resize calculations. I was hoping that applying a alapha mask to black areas and creating RGBA image then performing the resample would fix the issue but no such luck. any ideas? -- http://

Re: create boolean

2009-03-06 Thread Rhodri James
On Fri, 06 Mar 2009 15:34:08 -, Grant Edwards wrote: On 2009-03-06, Fencer wrote: Hi, I need a boolean b to be true if the variable n is not None and not an empty list, otherwise b should be false. I ended up with: b = n is not None and not not n I'd do it like this: b = (n is

Re: where is the PyString_AsString in Python 3.0?

2009-03-06 Thread BigHand
On Mar 7, 3:50 am, Benjamin Peterson wrote: > BigHand gmail.com> writes: > > > > There is no PyString_AsString. Everything > >> string is unicode now. (PyUnicode API) > > hello,Ben, > > could you give me an example? I almost know the > > PyUnicode API,but the > > docs of 3.0 is too brief for me.

Re: Bizarre import duplication.

2009-03-06 Thread Gabriel Genellina
En Fri, 06 Mar 2009 22:05:53 -0200, Richard Thomas escribió: Say I have a project like this: ./run.py ./package/__init__.py ./package/mod1.py ./package/subpackage/__init__.py ./package/subpackage/mod2.py ./package/subpackage/mod3.py And suppose that "." and "package"

Re: "/a" is not "/a" ?

2009-03-06 Thread Steven D'Aprano
Gary Herron wrote: >>> Newbies: Never use "is" to compare anything. >> >> Worse and worse! Now you're actively teaching newbies to write buggy >> code! > > Nonsense.  Show me "newbie" level code that's buggy with "==" but > correct with "is". What's "newbie" level code? What does that even *mean

Re: "/a" is not "/a" ?

2009-03-06 Thread skip
Steven> Mutable versus immutable is irrelevant. The complexity of the Steven> object is irrelevant. The phase of the moon is irrelevant. The Steven> *only* relevant factor is the programmer's intention: Which for a new user not familiar with the differing concepts of "is" and "==" can

Re: "/a" is not "/a" ?

2009-03-06 Thread Robert Kern
On 2009-03-06 18:29, Paul Rubin wrote: Steven D'Aprano writes: It is never correct to avoid using "is" when you need to compare for identity. When is it ever necessary to compare for identity? Caches of arbitrary objects. When checking if an object (which may be have an arbitrarily pervers

Re: "/a" is not "/a" ?

2009-03-06 Thread Steven D'Aprano
s...@pobox.com wrote: > Of course, the more complex the objects you are comparing the > stronger the recommendation agaist using 'is' to compare two objects. Why is there so much voodoo advice about "is"? Is object identity really such a scary concept that people are frightened of it? Mutable ve

Re: "/a" is not "/a" ?

2009-03-06 Thread Paul Rubin
Steven D'Aprano writes: > It is never > correct to avoid using "is" when you need to compare for identity. When is it ever necessary to compare for identity? -- http://mail.python.org/mailman/listinfo/python-list

Re: uniqueness of temporary files generated by tempfile

2009-03-06 Thread Emile van Sebille
Catherine Moroney wrote: Are the temporary filenames generated by the tempfile module guaranteed to be unique? I suspect this answers your question... Emile >>> import tempfile >>> help(tempfile) Help on module tempfile: NAME tempfile - Temporary files. FILE c:\python25\lib\tempfil

Re: Asking for prophecy

2009-03-06 Thread Terry Reedy
Stefan Spoettl wrote: In the pass it was always a good idea to use the newest Python verison for starting the development of a new application. First one could benefit from the additional features and second one could be sure that the community would have been passing during development. Nowa

Re: Parsing/Crawler Questions - solution

2009-03-06 Thread rounderweget
So, it sounds like your update means that it is related to a specific url. I'm curious about this issue myself. I've often wondered how one could properly crawl an AJAX-ish site when you're not sure how quickly the data will be returned after the page has been. John, your advice has really helpe

Re: ANN: Dao, the official 1.0 version is released

2009-03-06 Thread Ben Finney
Daniel Fetchinson writes: > Why this hostility? The guy has worked on an interesting piece of > software and tries to promote it to people who are most probably > interested in programming languages. What's wrong with that? Because there's no particular reason for it to be in a Python-specific f

Bizarre import duplication.

2009-03-06 Thread Richard Thomas
Say I have a project like this: ./run.py ./package/__init__.py ./package/mod1.py ./package/subpackage/__init__.py ./package/subpackage/mod2.py ./package/subpackage/mod3.py And suppose that "." and "package" (or their absolute paths) are in sys.path. Now mod1.py and mod2.p

Re: "/a" is not "/a" ?

2009-03-06 Thread Carl Banks
On Mar 6, 12:23 pm, Gary Herron wrote: > Robert Kern wrote: > > On 2009-03-06 13:46, Gary Herron wrote: > >> Emanuele D'Arrigo wrote: > >>> Hi everybody, > > >>> while testing a module today I stumbled on something that I can work > >>> around but I don't quite understand. > > >> *Do NOT use "is"

uniqueness of temporary files generated by tempfile

2009-03-06 Thread Catherine Moroney
Are the temporary filenames generated by the tempfile module guaranteed to be unique? I have a need to generate temporary files within an application, and I will have many instances of this application running as a sub-process (so I can submit them to a batch queue). Is there any danger of my di

Re: "/a" is not "/a" ?

2009-03-06 Thread Gabriel Genellina
En Fri, 06 Mar 2009 19:31:02 -0200, Emanuele D'Arrigo escribió: a = "a" b = "a" a is b True a = "/a" <- same as above, except the forward slashes! b = "/a" <- same as above, except the forward slashes! a is b False So, it appears that in the first case a and b are names to the same str

Re: searching for an easy library to create OpenOffice spreadsheets

2009-03-06 Thread Terry Reedy
Krishnakant wrote: Hello all, I am looking out for a python library which does the followingg. 1, create and manipulate openoffice spreadsheets. OpenOffice, by default, creates ODF -- Open Document Format -- documents as zipped xml subdocuments. Ooo is just one of many programs that work wit

Re: How to replace the two last digits from an xml file?

2009-03-06 Thread odeits
On Mar 6, 3:31 pm, odeits wrote: > On Mar 6, 11:53 am, awel wrote: > > > > > Hi, > > > I am trying to get a value from an xml file, increment it by 1, > > replace by the new value and write another xml with the new value > > inside. > > > I have found this code to get the line and it works but I

Re: Reading Special Administration Console (SAC) in python

2009-03-06 Thread Emile van Sebille
krishnakishore.nakarika...@gmail.com wrote: I want to read the Special Administration Console (SAC) output spew using python. Is it possible for me? It looks like that's just serial port I/O. If that doesn't get you going in the right direction it'll be a tough road... Emile -- http://ma

Re: Should I use stackless python or threads?

2009-03-06 Thread Minesh Patel
On Fri, Mar 6, 2009 at 3:16 PM, Jean-Paul Calderone wrote: > On Fri, 6 Mar 2009 14:50:51 -0800, Minesh Patel wrote: >> >> I am trying to figure out the best approach to solve this problem: >> >> I want to poll various directories(can be run in the main thread). >> Once I notice a file has been ad

Re: How to replace the two last digits from an xml file?

2009-03-06 Thread odeits
On Mar 6, 11:53 am, awel wrote: > Hi, > > I am trying to get a value from an xml file, increment it by 1, > replace by the new value and write another xml with the new value > inside. > > I have found this code to get the line and it works but I have to do > everything manualy: > > import re > lin

Re: Is there a better way of doing this?

2009-03-06 Thread mattia
Il Fri, 06 Mar 2009 14:13:47 -0800, Scott David Daniels ha scritto: > mattia wrote: >> Here is my last shot, where I get rid of all the old intermediate >> functions: >> >> def selection(fitness, population): >> lp = len(population) >> roulette_wheel = [] >> for x in population: >>

Re: ANN: Dao, the official 1.0 version is released

2009-03-06 Thread Terry Reedy
Daniel Fetchinson wrote: This is to announce the first official release of Dao. Dao is a simple yet powerful object-oriented programming language So, you pimp your language in news groups for other languages? I see your off topic post in 3 language groups I frequent, that's not the way to get

Re: Should I use stackless python or threads?

2009-03-06 Thread Jean-Paul Calderone
On Fri, 6 Mar 2009 14:50:51 -0800, Minesh Patel wrote: I am trying to figure out the best approach to solve this problem: I want to poll various directories(can be run in the main thread). Once I notice a file has been added to any directory, I grab a lock, spawn a thread to go perform the nece

Re: ANN: Dao, the official 1.0 version is released

2009-03-06 Thread skip
Limin> Honest to say, there is no solid connection between Dao and Limin> Python. It's just that I had received some good suggestions and Limin> comments from these groups when I made a few previous Limin> announcements in these groups. So I guessed somebody might be Limin> i

Re: "/a" is not "/a" ?

2009-03-06 Thread skip
Gary> *Do NOT use "is" to compare immutable types.* **Ever! ** The obvious followup question is then, "when is it ok to use 'is'?" Robert> Well, "foo is None" is actually recommended practice Indeed. It does have some (generally small) performance ramifications as well. Two trivia

Re: "/a" is not "/a" ?

2009-03-06 Thread Gary Herron
Emanuele D'Arrigo wrote: On 6 Mar, 19:46, Gary Herron wrote: It is an implementation choice (usually driven by efficiency considerations) to choose when two strings with the same value are stored in memory once or twice. In order for Python to recognize when a newly created string has the

Should I use stackless python or threads?

2009-03-06 Thread Minesh Patel
I am trying to figure out the best approach to solve this problem: I want to poll various directories(can be run in the main thread). Once I notice a file has been added to any directory, I grab a lock, spawn a thread to go perform the necessary actions, and then release the lock. -- Thanks for

Re: "/a" is not "/a" ?

2009-03-06 Thread Martin v. Löwis
> So, it appears that in the first case a and b are names to the same > string object, while in the second case they are to two separate > objects. Why? This question is ambiguous: a) Why does the Python interpreter behave this way? (i.e. what specific algorithm produces this result?) or b) Why

Re: "/a" is not "/a" ?

2009-03-06 Thread Gary Herron
Steven D'Aprano wrote: Gary Herron wrote: Robert Kern wrote: ... Use "is" when you really need to compare by object identity and not value. But that definition is the *source* of the trouble. It is *completely* meaningless to newbies. Until one has experience in programm

Re: ANN: Dao, the official 1.0 version is released

2009-03-06 Thread Limin Fu
> i agree it's not clear how this is related to python (although i can see > the influence), but it does look like a nice language. thanks. > > one thing i was surprised to find missing was that the discussion of types > doesn't include classes (the discussion of macros doesn't include types, A

Re: qt, gtk, wx for py3 ?

2009-03-06 Thread Peter Billam
On 2009-03-03, Mike Driscoll wrote: > It should be noted that the port for 3.0 hasn't started yet for > wxPython and I'm not seeing anything about a port for PyQt either > on their website. On 2009-03-05, Peter Billam wrote: > I mailed riverbankcomputing about PyQt for Py3; Phil Thompson replied

Re: ANN: Dao, the official 1.0 version is released

2009-03-06 Thread Daniel Fetchinson
>> This is to announce the first official release of Dao. >> >> Dao is a simple yet powerful object-oriented programming language > > So, you pimp your language in news groups for other languages? I see > your off topic post in 3 language groups I frequent, that's not the way > to get interest in

Re: Is there a better way of doing this?

2009-03-06 Thread mattia
Il Fri, 06 Mar 2009 18:46:44 -0300, andrew cooke ha scritto: > i have not been following this discussion in detail, so someone may have > already explained this, but it should not be necessary to actually > construct the roulette wheel to select values from it. what you are > doing is selecting f

Re: Is there a better way of doing this?

2009-03-06 Thread Scott David Daniels
mattia wrote: Here is my last shot, where I get rid of all the old intermediate functions: def selection(fitness, population): lp = len(population) roulette_wheel = [] for x in population: roulette_wheel += [x]*fitness(x) selected_population = [[]]*lp selected_popula

doctest + shelve question

2009-03-06 Thread Sebastian Bartos
Hello list, I have a question. I'm writing a simple object serialization module using shelve to write arbitrary objects to a file (M.py). Now I have the problem, that if I create a simple object in the doctest documentation file M.txt like this: >>> class tdata(object): ... def __init

Re: "/a" is not "/a" ?

2009-03-06 Thread Christian Heimes
Emanuele D'Arrigo wrote: > So, it appears that in the first case a and b are names to the same > string object, while in the second case they are to two separate > objects. Why? What's so special about the forward slash that cause the > two "/a" strings to create two separate objects? Is this an >

Re: how to prevent python import from looking into the current directory

2009-03-06 Thread TP
Benjamin Peterson wrote: > While the solutions given by others in this thread will work, I think it > is best policy to not name your own modules after stdlib ones. When I see > "os" referenced in code, I assume it is the stdlib one, and don't want to > be confused by the presence of your own modu

Re: Is there a better way of doing this?

2009-03-06 Thread andrew cooke
i have not been following this discussion in detail, so someone may have already explained this, but it should not be necessary to actually construct the roulette wheel to select values from it. what you are doing is selecting from a list where the there are different probabilities of selecting d

Re: "/a" is not "/a" ?

2009-03-06 Thread Emanuele D'Arrigo
On 6 Mar, 19:46, Gary Herron wrote: > It is an implementation choice (usually driven by efficiency considerations) > to choose when two strings with the same value are stored in memory once or > twice.  In order for Python to recognize when a newly created string has the > same value as an alre

Re: Is there a better way of doing this?

2009-03-06 Thread mattia
Il Fri, 06 Mar 2009 22:28:00 +0100, Peter Otten ha scritto: > mattia wrote: > >> Il Fri, 06 Mar 2009 14:06:14 +0100, Peter Otten ha scritto: >> >>> mattia wrote: >>> Hi, I'm new to python, and as the title says, can I improve this snippet (readability, speed, tricks): def g

Re: how to prevent python import from looking into the current directory

2009-03-06 Thread Benjamin Peterson
TP Paralleles.invalid> writes: > > Hi everybody, > > I would like to prevent the loading of modules in the current directory. > For example, if I have a personal module in the current directory > named "os", when I do "import os", I would like Python to import os > standard module, not my perso

Re: "/a" is not "/a" ?

2009-03-06 Thread Emanuele D'Arrigo
Thank you everybody for the contributions and sorry if I reawoke the recurring "is vs ==" issue. I -think- I understand how Python's object model works, but clearly I'm still missing something. Let me reiterate my original example without the distracting aspect of the "==" comparisons and the four

python image - ignore values in resize

2009-03-06 Thread Travis Kirstine
I have be attempting to resize (downsample) a RGB image using the python image library resize function. Everything works fine but I would like to exclude black values 0,0,0 from the calculations. I have tried creating a alpha mask based on black values then performing the resize but that only cre

Re: ANN: Dao, the official 1.0 version is released

2009-03-06 Thread Limin Fu
> > i agree it's not clear how this is related to python (although i can see > the influence), but it does look like a nice language. thanks. > > > one thing i was surprised to find missing was that the discussion of types > doesn't include classes (the discussion of macros doesn't include Ac

Re: Is there a better way of doing this?

2009-03-06 Thread Peter Otten
mattia wrote: > Il Fri, 06 Mar 2009 14:06:14 +0100, Peter Otten ha scritto: > >> mattia wrote: >> >>> Hi, I'm new to python, and as the title says, can I improve this >>> snippet (readability, speed, tricks): >>> >>> def get_fitness_and_population(fitness, population): >>> return [(fitness(

Re: "/a" is not "/a" ?

2009-03-06 Thread Steven D'Aprano
Gary Herron wrote: >> Huh? How am I supposed to compare immutable types for identity then? Your >> bizarre instruction would prohibit: >> >> if something is None >> > > Just use: > > if something == None > > It does *exactly* the same thing. Wrong. "something is None" is a pointer compar

Re: "/a" is not "/a" ?

2009-03-06 Thread Steven D'Aprano
Gary Herron wrote: > Robert Kern wrote: ... >> Use "is" when you really need to compare by object identity and not >> value. > > But that definition is the *source* of the trouble. It is *completely* > meaningless to newbies. Until one has experience in programming in > general and experience

Re: "/a" is not "/a" ?

2009-03-06 Thread Gary Herron
Steven D'Aprano wrote: Gary Herron wrote: Emanuele D'Arrigo wrote: Hi everybody, while testing a module today I stumbled on something that I can work around but I don't quite understand. *Do NOT use "is" to compare immutable types.***Ever! ** Huh? How am I suppos

Re: A Simple Tkinter Control Program--Slight Problem

2009-03-06 Thread W. eWatson
I like to see closure on a thread. This should do it. from Tkinter import * # Use of control variables and callbacks def mycallback(): print "User entered:" , e.get() print "Operation by 2 gives: ", e.get()*2, "and", v.get()*2 master = Tk() #v=StringVar() v=IntVar() print v,type(v) pri

Re: This should be a simple question...

2009-03-06 Thread andrew cooke
Steven D'Aprano wrote: > Steve Holden wrote: > >> If x and b are meant to be global than bite the bullet and *make* them >> global. > > Well, there's global, and there's global. > > There's global to a few functions in a module, there's global to > everything > in a module, and global to an entire

Re: This should be a simple question...

2009-03-06 Thread Steven D'Aprano
Steve Holden wrote: > If x and b are meant to be global than bite the bullet and *make* them > global. Well, there's global, and there's global. There's global to a few functions in a module, there's global to everything in a module, and global to an entire application. They're not necessarily t

Re: "/a" is not "/a" ?

2009-03-06 Thread Gary Herron
Robert Kern wrote: On 2009-03-06 14:23, Gary Herron wrote: Robert Kern wrote: On 2009-03-06 13:46, Gary Herron wrote: Emanuele D'Arrigo wrote: Hi everybody, while testing a module today I stumbled on something that I can work around but I don't quite understand. *Do NOT use "is" to compare

Re: "/a" is not "/a" ?

2009-03-06 Thread Steven D'Aprano
Emanuele D'Arrigo wrote: > Hi everybody, > > while testing a module today I stumbled on something that I can work > around but I don't quite understand. Why do you have to work around it? What are you trying to do that requires that two strings should occupy the same memory location rather than

Re: "/a" is not "/a" ?

2009-03-06 Thread Steven D'Aprano
Gary Herron wrote: > Emanuele D'Arrigo wrote: >> Hi everybody, >> >> while testing a module today I stumbled on something that I can work >> around but I don't quite understand. >> > > *Do NOT use "is" to compare immutable types.***Ever! ** Huh? How am I supposed to compare immutable type

Re: "/a" is not "/a" ?

2009-03-06 Thread Robert Kern
On 2009-03-06 14:23, Gary Herron wrote: Robert Kern wrote: On 2009-03-06 13:46, Gary Herron wrote: Emanuele D'Arrigo wrote: Hi everybody, while testing a module today I stumbled on something that I can work around but I don't quite understand. *Do NOT use "is" to compare immutable types.* *

Re: "/a" is not "/a" ?

2009-03-06 Thread Gary Herron
Robert Kern wrote: On 2009-03-06 13:46, Gary Herron wrote: Emanuele D'Arrigo wrote: Hi everybody, while testing a module today I stumbled on something that I can work around but I don't quite understand. *Do NOT use "is" to compare immutable types.* **Ever! ** Well, "foo is None" is actual

Re: Asking for prophecy

2009-03-06 Thread Mensanator
On Mar 6, 1:23 pm, "andrew cooke" wrote: > 3 and 2.6 are compatible.  so develop on 3, to make sure you don't use old > junk, and then switch to 2.6 if you need to.  there are a few wrinkles in > doing so, but it is not a big problem. > > 3.0 is a nicer language.  it's cleaner and more consistent.

Re: "/a" is not "/a" ?

2009-03-06 Thread John Nagle
Gary Herron wrote: Emanuele D'Arrigo wrote: Hi everybody, while testing a module today I stumbled on something that I can work around but I don't quite understand. *Do NOT use "is" to compare immutable types.***Ever! ** Then it should be a detected error to do so.

Re: "/a" is not "/a" ?

2009-03-06 Thread Robert Kern
On 2009-03-06 13:46, Gary Herron wrote: Emanuele D'Arrigo wrote: Hi everybody, while testing a module today I stumbled on something that I can work around but I don't quite understand. *Do NOT use "is" to compare immutable types.* **Ever! ** Well, "foo is None" is actually recommended pract

Re: Indentations and future evolution of languages

2009-03-06 Thread Tim Rowe
2009/3/6 : > This is an interesting post, it shows me that fitness plateau where > design of Python syntax lives is really small, you can't design > something just similar: > > http://unlimitednovelty.com/2009/03/indentation-sensitivity-post-mortem.html I don't think the article is right that "it

How to replace the two last digits from an xml file?

2009-03-06 Thread awel
Hi, I am trying to get a value from an xml file, increment it by 1, replace by the new value and write another xml with the new value inside. I have found this code to get the line and it works but I have to do everything manualy: import re lines = open("c:\\File1.xml").readlines() for i in rang

Re: where is the PyString_AsString in Python 3.0?

2009-03-06 Thread Benjamin Peterson
BigHand gmail.com> writes: > > There is no PyString_AsString. Everything >> string is unicode now. (PyUnicode API) > hello,Ben, > could you give me an example? I almost know the > PyUnicode API,but the > docs of 3.0 is too brief for me. PyString_FromString -> PyUnicode_FromString PyString_Concat

Re: "/a" is not "/a" ?

2009-03-06 Thread Gary Herron
Emanuele D'Arrigo wrote: Hi everybody, while testing a module today I stumbled on something that I can work around but I don't quite understand. *Do NOT use "is" to compare immutable types.***Ever! ** It is an implementation choice (usually driven by efficiency considerations) to cho

Re: "/a" is not "/a" ?

2009-03-06 Thread Joshua Kugler
Emanuele D'Arrigo wrote: c = "/a" d = "/a" c == d > True # all good so far c is d > False # ek! > > Why c and d point to two different objects with an identical string > content rather than the same object? Because you instantiated two difference

searching for an easy library to create OpenOffice spreadsheets

2009-03-06 Thread Krishnakant
Hello all, I am looking out for a python library which does the followingg. 1, create and manipulate openoffice spreadsheets. 2, allow for cell formatting including merging cells. 3, allow for colouring cells and formatting data as bold italics etc. 4, alignment of data should be possible. I looked

Re: ANN: Dao, the official 1.0 version is released

2009-03-06 Thread Tim Greer
Limin Fu wrote: > To Tim Greer and others: > > Some people may think this kind of announcement are off topic in a > group for another language. This is not exactly true. This is still > about programming, there are so many programmers out there, who knows > if there would be somebody interested i

Re: ANN: Dao, the official 1.0 version is released

2009-03-06 Thread Limin Fu
Honest to say, there is no solid connection between Dao and Python. It's just that I had received some good suggestions and comments from these groups when I made a few previous announcements in these groups. So I guessed somebody might be interested in Dao, and thought it might be a good idea to a

Re: Unusual Python interpreter problem with os.fork()

2009-03-06 Thread DLitgo
On Mar 6, 7:20 am, Jean-Paul Calderone wrote: > On Fri, 6 Mar 2009 05:00:03 -0800 (PST), DLitgo wrote: > >Hello everyone, > > >I have a curious problem which I'm wondering if anyone here can shed > >some light on. I'm basically just following along with a guide which > >is going through some of t

Re: Reading from text

2009-03-06 Thread Paul McGuire
On Feb 17, 11:03 am, oamram wrote: > Hi All, > new to python. i have a directory with about 50 text file and i need to > iterate through them and get > line 7 to 11 from each file and write those lines into another file(one file > that will contain all lines). > import glob file("output.txt","w")

Re: Asking for prophecy

2009-03-06 Thread andrew cooke
3 and 2.6 are compatible. so develop on 3, to make sure you don't use old junk, and then switch to 2.6 if you need to. there are a few wrinkles in doing so, but it is not a big problem. 3.0 is a nicer language. it's cleaner and more consistent. i think important libraries will move there. no

"/a" is not "/a" ?

2009-03-06 Thread Emanuele D'Arrigo
Hi everybody, while testing a module today I stumbled on something that I can work around but I don't quite understand. >>> a = "a" >>> b = "a" >>> a == b True >>> a is b True >>> c = "/a" >>> d = "/a" >>> c == d True # all good so far >>> c is d False # ek! Why c

Re: how to prevent python import from looking into the current directory

2009-03-06 Thread Ben Finney
(Could you please set a valid email address for people to contact you if necessary?) TP writes: > I would like to prevent the loading of modules in the current > directory. You will, I think, like the new distinction between “absolute” and “relative” imports http://www.python.org/dev/peps/pep-0

Asking for prophecy

2009-03-06 Thread Stefan Spoettl
In the pass it was always a good idea to use the newest Python verison for starting the development of a new application. First one could benefit from the additional features and second one could be sure that the community would have been passing during development. Nowadays we have at least th

Re: New User - Using tutorial and Docs - POST returns 302 Found

2009-03-06 Thread JohnV
> Sorry, I think you didn't get my later post -- than in fact was from a   > month ago... > Seehttp://article.gmane.org/gmane.comp.python.general/613312/ > urllib2 should handle a 302 redirect automatically. > > -- > Gabriel Genellina I went to the link you provided and sure enough there was your

Re: Winsound Problems on Vista 64

2009-03-06 Thread Terry Reedy
Casey wrote: I have a new laptop that came with Vista 64 and I'm having problems with some of my older code that I use for multimedia processing. I narrowed the problem down to the winsound library; any attempt to play sounds results in a fatal error. The simplest case is: from winsound impor

  1   2   3   >