Re: Can string formatting be used to convert an integer to its binary form ?

2006-09-28 Thread MonkeeSage
Steve Holden wrote: > >>> to_bin(0) > '' Doh! Oh, yeah...that! ;) OK... def to_bin(x): out=[] while x > 0: out.insert(0, str(x % 2)) x /= 2 else: out.append(str(x)) return ''.join(out) Regards, Jordan -- http://mail.python.org/mailman/listinfo/python-list

Re: analyzing removable media

2006-09-28 Thread John Machin
glenn wrote: > Hi Jay > pls excuse top post - Im actually doing this project in linux, but am > wanting it to be cross platform. I definitley have to cater for win32 > also. I was hoping that burried in sys or os or that there'd be some x > platform module that did all that stuff for me > Thin

Re: analyzing removable media

2006-09-28 Thread glenn
Hi Jay pls excuse top post - Im actually doing this project in linux, but am wanting it to be cross platform. I definitley have to cater for win32 also. I was hoping that burried in sys or os or that there'd be some x platform module that did all that stuff for me thnks for reply though glenn J

Re: Can string formatting be used to convert an integer to its binary form ?

2006-09-28 Thread George Sakkis
Steve Holden wrote: > MonkeeSage wrote: > > So far as unobfuscated versions go, how about the simple: > > > > def to_bin(x): > > out = [] > > while x > 0: > > out.insert(0, str(x % 2)) > > x = x / 2 > > return ''.join(out) > > > > Regards, > > Jordan > > > >>> to_bin(0) > '' > > 6/

Re: analyzing removable media

2006-09-28 Thread Jay
Well, in linux you can get a lot of info about where a file is based upon where it lies in the file system. For example, if the folder the file is located in resides in the /media or /mnt directories, then the file is, barring a few rare circumstances, located upon a removable medium of some sort.

Re: Can string formatting be used to convert an integer to its binary form ?

2006-09-28 Thread Paul Rubin
"MonkeeSage" <[EMAIL PROTECTED]> writes: > def to_bin(x): > out = [] > while x > 0: > out.insert(0, str(x % 2)) > x = x / 2 > return ''.join(out) That returns the empty string for x=0. I'm not sure if that's a bug or a feature. It also returns the empty string for x < 0, probably a

Re: Questions on Using Python to Teach Data Structures and Algorithms

2006-09-28 Thread MonkeeSage
Dennis Lee Bieber wrote: > Though if this suddenly inspires the creation of a Common LISP > interpreter written in Python, I may want to close my eyes Hehe! I actually thought of trying that once, but I realized that I'm too stupid and / or lazy to pull it off. ;) Regards, Jordan -- http

Re: wxPython and threading issue

2006-09-28 Thread Steve Holden
Patrick Smith wrote: > Hi, > Thanks for your reply. > > <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > >>Patrick Smith wrote: >> >>>Hi, >>>I'm hoping someone here will be able to help as I've been struggling > > with > >>>this problem for a few days now. >>> >>>I'm working on a

Re: vector and particle effects

2006-09-28 Thread Jay
Sorry for the double post. Google groups was being stubborn. Jay wrote: > I'd like to experiment a little bit with vector graphics in python. > When I say 'vector graphics' I don't mean regular old svg-style. I > mean vector game style as in simulation of vector beam drawn graphics. > If you stil

Re: Making sure script only runs once instance at a time.

2006-09-28 Thread Stephan Kuhagen
Hari Sekhon wrote: > I have written a script and I would like to ensure that the script is > never run more than once at any given time. > > What is the best way of testing and exiting if there is another version > of this script running somewhere on this machine? > > I guess what I'm asking is

Re: Can string formatting be used to convert an integer to its binary form ?

2006-09-28 Thread Steve Holden
MonkeeSage wrote: > So far as unobfuscated versions go, how about the simple: > > def to_bin(x): > out = [] > while x > 0: > out.insert(0, str(x % 2)) > x = x / 2 > return ''.join(out) > > Regards, > Jordan > >>> to_bin(0) '' 6/10: try harder :) regards Steve -- Steve Holden

Re: AN Intorduction to Tkinter

2006-09-28 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: >> Since the examples out of An Introduction to Tkinter work, what else >> could be useful to you is hard to guess. > > Basically, any kind of program using Tkinter, and has some sort of > usefulness you don't seem to have noticed, but you *still* haven't explained what

$1 MILLION REWARD for a simple paper in PHYSICS -- CONTROLLED DEMOLITION HOAX of 9/11

2006-09-28 Thread thermate
Copy and paste from the site on 911 http://reopen911.org/ $1 Million Challenge Details This is void where prohibited by law: including but not limited to Colorado , Maryland , Nebraska , North Dakota, Vermont, New Jersey and Tennessee. It is void anywhere prohibited by law. The contest page supe

analyzing removable media

2006-09-28 Thread glenn
Hi can anyone tell me how given a directory or file path, I can pythonically tell if that item is on 'removable media', or sometype of vfs, the label of the media (or volume) and perhaps any other details about the media itself? thanks Glenn -- http://mail.python.org/mailman/listinfo/python-list

Re: Can string formatting be used to convert an integer to its binary form ?

2006-09-28 Thread MonkeeSage
So far as unobfuscated versions go, how about the simple: def to_bin(x): out = [] while x > 0: out.insert(0, str(x % 2)) x = x / 2 return ''.join(out) Regards, Jordan -- http://mail.python.org/mailman/listinfo/python-list

Re: Can string formatting be used to convert an integer to its binary form ?

2006-09-28 Thread George Sakkis
Gabriel Genellina wrote: > At Thursday 28/9/2006 22:07, Lawrence D'Oliveiro wrote: > > >How about this: (where n is the integer you want to convert): > > > > "".join([["0", "1"][(1 << i & n) != 0] for i in > > range(int(math.ceil(math.log(n, 2))) - 1, -1, -1)]) > > Uhm... so to generate a bina

Re: Questions on Using Python to Teach Data Structures and Algorithms

2006-09-28 Thread MonkeeSage
sturlamolden wrote: > Thus I stand by my original claim. Essentlially: > > def cons(car,cdr): return (car,cdr) # or [car,cdr] > def car(cons): return cons[0] > def cdr(cons): return cons[1] I guess you were talking about implementing the _structure_ of lisp lists in python syntax (as you seem to i

Using vim in server mode with ipython

2006-09-28 Thread James Stroud
Hello, I found this page: http://projects.scipy.org/ipython/ipython/wiki/CookBook#Usinggviminservermode But it does not seem to work for me. I set the editor in ipythonrc to gvim. Then I followed the instructions, step by step. To needlessly paraphrase the instructions: [0. I started g

Re: running commands with sudo & python

2006-09-28 Thread John Bauman
[EMAIL PROTECTED] wrote: > Hi! > I must execute a command with os.command(), but with root permissions. > Is there anyway to do that with python? > Thanks > http://en.wikipedia.org/wiki/Setuid Of course, it's not generally a good idea to have your program keep root permissions after it does what

Re: wxPython and threading issue

2006-09-28 Thread Patrick Smith
Hi, Thanks for your reply. <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Patrick Smith wrote: > > Hi, > > I'm hoping someone here will be able to help as I've been struggling with > > this problem for a few days now. > > > > I'm working on an application that is creating a Progress

Re: wxPython and threading issue

2006-09-28 Thread [EMAIL PROTECTED]
Patrick Smith wrote: > Hi, > I'm hoping someone here will be able to help as I've been struggling with > this problem for a few days now. > > I'm working on an application that is creating a ProgressDialog, and then > creating a thread that runs a function from another module in the program. > > Th

Re: sqlite3 error

2006-09-28 Thread John Machin
Steve Holden wrote: > John Machin wrote: > > John Salerno wrote: > > > >>John Machin wrote: > >> > >>>John Salerno wrote: > >>> > CREATE TABLE Researchers ( > researcherID varchar(9) PRIMARY KEY NOT NULL, > birthYear int(4) DEFAULT NULL, > birthMonth int(2) DEFAULT N

Re: Can string formatting be used to convert an integer to its binary form ?

2006-09-28 Thread Gabriel Genellina
At Thursday 28/9/2006 22:07, Lawrence D'Oliveiro wrote: How about this: (where n is the integer you want to convert): "".join([["0", "1"][(1 << i & n) != 0] for i in range(int(math.ceil(math.log(n, 2))) - 1, -1, -1)]) Uhm... so to generate a binary string you have to import the math mod

wxPython and threading issue

2006-09-28 Thread Patrick Smith
Hi, I'm hoping someone here will be able to help as I've been struggling with this problem for a few days now. I'm working on an application that is creating a ProgressDialog, and then creating a thread that runs a function from another module in the program. The problem is, when the cancel butto

Re: PATCH: Speed up direct string concatenation by 20+%!

2006-09-28 Thread Steve Holden
Larry Hastings wrote: > This is such a long posting that I've broken it out into sections. > Note that while developing this patch I discovered a Subtle Bug > in CPython, which I have discussed in its own section below. > [...] > __ > THE SUBMISSION > > I don't know the protocol from

Re: Recursive descent algorithm able to parse Python?

2006-09-28 Thread Gabriel Genellina
At Thursday 28/9/2006 17:00, Michael wrote: [EMAIL PROTECTED] wrote: > I'm a compiler newbie and curious if Python grammar is able to > be parsed by a recursive descent parser or if it requires > a more powerful algorithm. Python is relatively simple to parse using a recursive descent parser.

PATCH: Speed up direct string concatenation by 20+%!

2006-09-28 Thread Larry Hastings
This is such a long posting that I've broken it out into sections. Note that while developing this patch I discovered a Subtle Bug in CPython, which I have discussed in its own section below. THE OVERVIEW I don't remember where I picked it up, but I remember reading years ago that th

Re: Questions on Using Python to Teach Data Structures and Algorithms

2006-09-28 Thread Gabriel G
At Thursday 28/9/2006 12:23, Ramon Diaz-Uriarte wrote: Going back to the original question, a related question: does anybody know why there are so few books on data structures and algorithms that use Python? I remember that, at least ~ 12 years ago there were many (and very good) books that use

Re: sqlite3 error

2006-09-28 Thread Steve Holden
John Machin wrote: > John Salerno wrote: > >>John Machin wrote: >> >>>John Salerno wrote: >>> CREATE TABLE Researchers ( researcherID varchar(9) PRIMARY KEY NOT NULL, birthYear int(4) DEFAULT NULL, birthMonth int(2) DEFAULT NULL, birthDay int(2) DEFAULT NULL

Re: sqlite3 error

2006-09-28 Thread Paul Rubin
"John Machin" <[EMAIL PROTECTED]> writes: > It gets better: > > Iceland:... > Portuguese:... > [parts of] Somalia, Ethiopia:... > Vietnamese:... You might add something about Arabic filionyms. -- http://mail.python.org/mailman/listinfo/python-list

Re: sqlite3 error

2006-09-28 Thread John Machin
John Salerno wrote: > John Machin wrote: > > John Salerno wrote: > >> CREATE TABLE Researchers ( > >> researcherID varchar(9) PRIMARY KEY NOT NULL, > >> birthYear int(4) DEFAULT NULL, > >> birthMonth int(2) DEFAULT NULL, > >> birthDay int(2) DEFAULT NULL, > >> birthCountry

Re: windev vs python SOS

2006-09-28 Thread jmdeschamps
MC wrote: > Bonjour ! > > Comme tu es français, tu me coprendras. > > Alors : > - windev est fermé, et protégé par des dongles. Résultat : dongle > perdu, en panne, ou volé, il faut racheter une licence (c'est arrivé à > un ami) > - le langage de windev est beaucoup moins évolué que Python. Et

Fwd: RE: [Python-Help] Python Help

2006-09-28 Thread Gabriel Genellina
Forwarding full message to the Python list: Hello, I am trying to create a script. I have most of it wrote, but it isn't working like it should. Could you please take a look and let me know whats wrong with it? What happens is that there is an array that is created and I verified the information

Thanks to DSA Q. Repliers (was: Re: Questions on Using Python to Teach Data Structures...)

2006-09-28 Thread efrat
efrat wrote: > Hello, > > I'm planning to use Python in order to teach a DSA (data structures > and algorithms) course ... Hello, Many thanks, repliers, for the informative and useful answers. Bye, Efrat -- http://mail.python.org/mailman/listinfo/python-list

Re: How to get ip setting, dynamic ip or static ip?

2006-09-28 Thread kode4u
Thank you very much. Does the wmi object can modify the ip address? Roger Upole wrote: > This means the unicode object contains characters that > can't be represented in the default encoding. Try encoding it > in another character set, something like > > adapter.Properties_['Caption'].Value.enco

Re: Can string formatting be used to convert an integer to its binary form ?

2006-09-28 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, I wrote: > "".join([["0", "1"][(1 << i & n) != 0] for i in > range(int(math.ceil(math.log(n, 2))) - 1, -1, -1)]) Uh, make that "".join([["0", "1"][(1 << i & n) != 0] for i in range(int(math.floor(math.log(n, 2))), -1, -1)]) Need to check those corner ca

Re: windev vs python SOS

2006-09-28 Thread Paddy
My french is attrocious so I got Michels original post machine transated. I liked what Michel was saying, maybe others would like to share: Hello! As you are French, you will coprendras me. Then: - windev is closed, and protected by dongles. Result: dongle lost, broken down, or flown, a licence s

Re: Can string formatting be used to convert an integer to its binary form ?

2006-09-28 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, [EMAIL PROTECTED] wrote: > Mirco Wahab: >> But where is the %b in Python? > > Python doesn't have that. You can convert the number to a hex, and then > map the hex digitds to binary strings using a dictionary, like this: > http://aspn.activestate.com/ASPN/Cookbook/

Re: releasing memory to malloc

2006-09-28 Thread iker . arizmendi
The workaround I went with made use of the shelve module and calls to gc.collect() to cap the memory consumed by the Python allocator. It was a bit intrusive but it got the job done. Would a method in the gc module that released memory to malloc be something that could get added to Python? Or are

Re: startswith() and endswith() for re's would be more intuitive

2006-09-28 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, metaperl wrote: > There is also nothing wrong with > > re.match('blah', somestring) > > but it does read as well as > > re.atstartof('blah', something) > > and the counterpart for EOS is not there. The only reason for those special cases for simple string match

Re: AN Intorduction to Tkinter

2006-09-28 Thread [EMAIL PROTECTED]
> Since the examples out of An Introduction to Tkinter work, what else > could be useful to you is hard to guess. Basically, any kind of program using Tkinter, and has some sort of usefulness btw, I DO look at signatures believe it or not, and already (as in before I even read this post) I have

Re: ANN: CherryPy 3.0.0 beta 2

2006-09-28 Thread Ben Finney
Ben Finney <[EMAIL PROTECTED]> writes: > Please don't post HTML message bodies to a public mailing list. My apologies; this was sent as a reply direct to the sender of the release announcement. I've no idea how it ended up here. -- \ "The WWW is exciting because Microsoft doesn't own

Re: QuoteSQL

2006-09-28 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, LI wrote: execfile("QuoteSQL.py") EscapeSQLWild(r"\%") > '%' SQLString("%" + EscapeSQLWild(r"\%") + "%") > '"%%%"' EscapeSQLWild(r"\%") == r"\\%" > True SQLString("%" + EscapeSQLWild(r"\%") + "%") == r'"%%%"' > True With the

Re: QuoteSQL

2006-09-28 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, I wrote: > def EscapeSQLWild(Str) : > """escapes MySQL pattern wildcards in Str.""" > Result = [] > for Ch in str(Str) : > if Ch == "%" or Ch == "_" : > Result.append("\\") > #end if > R

Re: Recursive descent algorithm able to parse Python?

2006-09-28 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Diez B. Roggisch wrote: > [EMAIL PROTECTED] schrieb: >> I'm a compiler newbie and curious if Python grammar is able to >> be parsed by a recursive descent parser or if it requires >> a more powerful algorithm. > > I might be mistaken, but isn't recursive descent on

Re: License / Registration key enabled software

2006-09-28 Thread Mike Playle
On Thu, 28 Sep 2006 18:44:13 +0200, Sybren Stuvel wrote: > Steve Holden enlightened us with: >> And you guarantee that the contents of the smartcard is only used by one >> user at a time by building a licensing system for the smartcards? > > We can never, ever make a 100% guarantee that people wo

Re: Python CTypes translation of (pv != NULL)

2006-09-28 Thread p . lavarre
Future Googlers might like this thread to end with the Thomas Heller's brief conclusive review: /// Copied 2006-09-28 from /// http://starship.python.net/crew/theller/moin.cgi/CodeSnippets 1.2 Check for NULL ctypes pointers The truth value of any NULL ctypes pointer instance is False. So, this

Re: ctypes.c_void_p(-1) might not be C return (void *) -1

2006-09-28 Thread p . lavarre
> I've started a wiki page where I already added an entry about the above > question. > Do you think the entry would have answered your question? > http://starship.python.net/crew/theller/moin.cgi/CodeSnippets As concise as I now can imagine, yes thank you. I see the main point leads: "The truth

Re: Can string formatting be used to convert an integer to its binary form ?

2006-09-28 Thread bearophileHUGS
Frederic Rentsch: > Good idea, but shorter with -> > >>> SE.SE ('se_definition_files/int_to_binary.se') ('%X' % 987654321) > '0011101011000110100010110001' Note that your version keeps the leading zeros. Have you tested the relative speeds too? (I'll probably have to learn to use SE.) Bye, b

Re: best way to get data into a new instance?

2006-09-28 Thread John Machin
Diez B. Roggisch wrote: > > The programmer is responsible for the construction of new instances (or > at least the code which will do that), and a constructor should contain > parameters for at least the values you absolutely expect to be there - > for example name and age or something like that

Re: eval(source, {'builtins': {}}) archived as Faq

2006-09-28 Thread Paul Rubin
[EMAIL PROTECTED] writes: > Q: How can I tell Python to calculate what quoted strings and numbers > mean, without also accidentally accepting OS commands as input? > > A: eval(source, {'builtins': {}}) That is dangerous. Consider source = "9**9**9". There's a better recipe on ASPN: http://aspn

Re: eval(source, {'builtins': {}}) archived as Faq

2006-09-28 Thread Erik Max Francis
[EMAIL PROTECTED] wrote: > Absent from http://www.python.org/doc/current/lib/built-in-funcs.html > but now copied to the Faq list of http://pyfaq.infogami.com/suggest, > from these clp archives: > > /// > > Q: How can I tell Python to calculate what quoted strings and numbers > mean, without als

Re: using the email module

2006-09-28 Thread Sybren Stuvel
Erik Johnson enlightened us with: > # Ah! Yes, that works! Thank you! ;) You're welcome! Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Can string formatting be used to convert an integer to its binary form ?

2006-09-28 Thread Mirco Wahab
Thus spoke Fredrik Lundh (on 2006-09-28 23:35): > Mirco Wahab wrote: > >> - why doesn't have Python such a simple and useful thing as to_binstr(...) > > useful? really? for what? I don't really know, but according to google, people often ask exactly for that and there is no reason at all why

Re: ANN: CherryPy 3.0.0 beta 2

2006-09-28 Thread Ben Finney
Please don't post HTML message bodies to a public mailing list. This release announcement contained nothing that requires anything but plain text, and HTML simply makes the document needlessly more complex to render. -- http://mail.python.org/mailman/listinfo/python-list

eval(source, {'builtins': {}}) archived as Faq

2006-09-28 Thread p . lavarre
Absent from http://www.python.org/doc/current/lib/built-in-funcs.html but now copied to the Faq list of http://pyfaq.infogami.com/suggest, from these clp archives: /// Q: How can I tell Python to calculate what quoted strings and numbers mean, without also accidentally accepting OS commands as in

Can recursive descent parser handle Python grammar?

2006-09-28 Thread [EMAIL PROTECTED]
I'm a compiler newbie and was curious if Python's language/grammar can be handled by a recursive descent parser. Well? Chris -- http://mail.python.org/mailman/listinfo/python-list

Re: Whither binary search?

2006-09-28 Thread John Machin
Sion Arrowsmith wrote: > John Machin <[EMAIL PROTECTED]> wrote: > >Fredrik Lundh wrote: > >> well, people tend to use dictionaries when they need to look things up > >> quickly... > >... like those paper dictionaries with the words in alphabetical order > >:-) > > ... where you'll notice that the

Re: releasing memory to malloc

2006-09-28 Thread iker . arizmendi
The workaround I've settled for uses the shelve module and calls to gc.collect() to put a cap on the amount of memory the Python allocator consumes. A bit more intrusive but it gets the job done. Would a gc method that released memory to malloc be something worth adding to Python? Or are there rea

Re: Resuming a program's execution after correcting error

2006-09-28 Thread MRAB
Sheldon wrote: > Hi. > > Does anyone know if one can resume a python script at the error point > after the error is corrected? > I have a large program that take forever if I have to restart from > scratch everytime. The error was the data writing a file so it seemed > such a waste if all the data

Re: What's the best way to communicate between processes?

2006-09-28 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, [EMAIL PROTECTED] wrote: > ... Don't top-post. -- http://mail.python.org/mailman/listinfo/python-list

Re: Making sure script only runs once instance at a time.

2006-09-28 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Hari Sekhon wrote: > I have written a script and I would like to ensure that the script is > never run more than once at any given time. -- http://mail.python.org/mailman/listinfo/python-list

Socks server and client code in Python (Twisted?)

2006-09-28 Thread Ben Kial
I'd like to create a Socks (4 or 5) server and client program using Python. Someone suggested me to use Twisted. Does anybody have any sample code for Socks server and client in Python? Thanks in advance, Ben -- http://mail.python.org/mailman/listinfo/python-list

Re: IDLE - Customizing output format

2006-09-28 Thread Ilias Lazaridis
Gabriel Genellina wrote: > At Wednesday 27/9/2006 09:29, Ilias Lazaridis wrote: > > >import sys > >def f(obj): > > if obj: > > print '::: ' + repr(obj) > >sys.displayhook = f > > Have you tried that? You have to filter out None, not *any* False value. you are right. 1 == 0 showed an em

Re: Can string formatting be used to convert an integer to its binary form ?

2006-09-28 Thread Mirco Wahab
Thus spoke Marc 'BlackJack' Rintsch (on 2006-09-28 23:38): >> def int2bin(num, width=32): >> return ''.join(['%c'%(ord('0')+bool((1<> range((width-1),-1,-1)]) > > Yeah, I wonder why not everybody sees the beauty in this cool and > straightforward one liner. ;-) Right. I see this is BS, ma

Tkinter Text widget incremental search

2006-09-28 Thread Bob Greschke
I want to create a search function on a Text() widget full of text like the incremental search in emacs -- if you type an "f" emacs goes to the first "f", type another "f" and it goes to the first place where "ff" shows up in the text, etc. How would you search the text of the Text() for a stri

Re: Recursive descent algorithm able to parse Python?

2006-09-28 Thread Diez B. Roggisch
[EMAIL PROTECTED] schrieb: > I'm a compiler newbie and curious if Python grammar is able to > be parsed by a recursive descent parser or if it requires > a more powerful algorithm. I might be mistaken, but isn't recursive descent one of the more powerful parsing techniques - for the price of non-

Re: releasing memory to malloc

2006-09-28 Thread Paul Rubin
Bryan Olson <[EMAIL PROTECTED]> writes: > I think I see what you're doing, but fork() after step 1 will > create a child process with the same memory allocated. > > I think it would make more sense to do step 1 in a subprocess. > Use the subprocess module or one of the older popen()s to create > a

Re: startswith() and endswith() for re's would be more intuitive

2006-09-28 Thread Fredrik Lundh
metaperl wrote: > Nothing. There is also nothing wrong with > > re.match('blah', somestring) > > but it does read as well as > > re.atstartof('blah', something) yuck. > and the counterpart for EOS is not there. sure is; it's spelled: re.match('.*blah$', somestring) -- http://mail.p

Re: Can string formatting be used to convert an integer to its binary form ?

2006-09-28 Thread Fredrik Lundh
Mirco Wahab wrote: > - why doesn't have Python such a simple and useful thing as to_binstr(...) useful? really? for what? -- http://mail.python.org/mailman/listinfo/python-list

Re: Can string formatting be used to convert an integer to its binary form ?

2006-09-28 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Mirco Wahab wrote: > Thus spoke Frederic Rentsch (on 2006-09-28 20:43): >> [EMAIL PROTECTED] wrote: >>> Mirco Wahab: >>> But where is the %b in Python? >>> >>> Python doesn't have that. ... >>> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440528 >> >>

Re: releasing memory to malloc

2006-09-28 Thread Bryan Olson
Paul Rubin wrote: > Is there any way to get Python to release memory back to the > C allocator? I'm currently running a script that goes through > the following steps: > > 1) Creates a very large number of Python objects to produce > a relatively small data structure that sits

Re: startswith() and endswith() for re's would be more intuitive

2006-09-28 Thread metaperl
Bruno Desthuilliers wrote: > metaperl wrote: > > I just finished answering a question in #python because someone tried > > to match using ... well.. match() > > but did not realize that match() is actually startswith() for regexps. > > Yet someone else that failed to read the Fine Manual(tm). > >

Re: windev vs python SOS

2006-09-28 Thread MC
Bonjour ! Comme tu es français, tu me coprendras. Alors : - windev est fermé, et protégé par des dongles. Résultat : dongle perdu, en panne, ou volé, il faut racheter une licence (c'est arrivé à un ami) - le langage de windev est beaucoup moins évolué que Python. Et, quand je dis beaucoup,

running commands with sudo & python

2006-09-28 Thread coldsoul4e
Hi! I must execute a command with os.command(), but with root permissions. Is there anyway to do that with python? Thanks -- http://mail.python.org/mailman/listinfo/python-list

Re: Can string formatting be used to convert an integer to its binary form ?

2006-09-28 Thread Mirco Wahab
Thus spoke Frederic Rentsch (on 2006-09-28 20:43): > [EMAIL PROTECTED] wrote: >> Mirco Wahab: >> >>> But where is the %b in Python? >> >> Python doesn't have that. ... >> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440528 > > Good idea, but shorter with -> > http://cheeseshop.pyt

Re: vector and particle effects

2006-09-28 Thread Diez B. Roggisch
Jay schrieb: > I'd like to experiment a little bit with vector graphics in python. > When I say 'vector graphics' I don't mean regular old svg-style. I > mean vector game style as in simulation of vector beam drawn graphics. > If you still don't know what I'm talking about, see Grid Wars 2 > (http

Re: best way to get data into a new instance?

2006-09-28 Thread James Stroud
James Stroud wrote: > John Salerno wrote: > >> Let's pretend I'm creating an Employee class, which I will later >> subclass for more specific jobs. Each instance will have stuff like a >> name, title, degrees held, etc. etc. >> >> So I'm wondering, is the best way to get all this information int

Re: best way to get data into a new instance?

2006-09-28 Thread James Stroud
John Salerno wrote: > Let's pretend I'm creating an Employee class, which I will later > subclass for more specific jobs. Each instance will have stuff like a > name, title, degrees held, etc. etc. > > So I'm wondering, is the best way to get all this information into the > object to just have

Re: Survival of the fittest

2006-09-28 Thread Dieter Maurer
Thomas Bartkus <[EMAIL PROTECTED]> writes on Tue, 26 Sep 2006 22:06:56 -0500: > ... > We would be curious to know about those things you can do in C++ > but can't do in Python. I implemented an incremental search engine in Python. It worked fine for large quite specific "and" queries (it was fast

Re: Questions on Using Python to Teach Data Structures and Algorithms

2006-09-28 Thread Ramon Diaz-Uriarte
On 9/28/06, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Ramon Diaz-Uriarte wrote: > > > Going back to the original question, a related question: does anybody > > know why there are so few books on data structures and algorithms that > > use Python? > > Probably because Python has "better than textbo

Re: preemptive OOP?

2006-09-28 Thread Steve Holden
John Salerno wrote: > Steve Holden wrote: > > >>However, if you want to simplify the code, you could start by saying >> >>myNotebook = wx.Notebook >> > > > I don't understand. Is that just a name change in the code? Let me put it this way: what doesn't it do that your code did? You're rig

Re: Questions on Using Python to Teach Data Structures and Algorithms

2006-09-28 Thread sturlamolden
Brendon Towle wrote: > ? (cons ) > > returns a single level list, with as its new first item, and > the original contents of as the remainder of the list. The > OP's code doesn't do that; it returns a list of two items, with > as the second item. That is equivalent, as is the remainder of t

Re: preemptive OOP?

2006-09-28 Thread John Salerno
Steve Holden wrote: > However, if you want to simplify the code, you could start by saying > > myNotebook = wx.Notebook > I don't understand. Is that just a name change in the code? -- http://mail.python.org/mailman/listinfo/python-list

Re: Recursive descent algorithm able to parse Python?

2006-09-28 Thread Michael
[EMAIL PROTECTED] wrote: > I'm a compiler newbie and curious if Python grammar is able to > be parsed by a recursive descent parser or if it requires > a more powerful algorithm. Python is relatively simple to parse using a recursive descent parser. If you're rolling your own as a learning exerci

Re: preemptive OOP?

2006-09-28 Thread Steve Holden
John Salerno wrote: > Erik Johnson wrote: > > >>My feeling is that there is no good reason to add the complexity of your >>own custom classes if they provide no additional data or behaviour. If you >>know you have plans to add your own attributes and/or methods to MyNotebook >>soon, there's n

Re: XSLT speed comparisons

2006-09-28 Thread Josh Bloom
Hey Damian, I suggest you take a look at http://mmm-experts.com/Products.aspx?ProductId=4 which is a nice open source Python IDE for windows. After you've installed the version from that page, you should go to http://groups.google.com/group/PyScripter?lnk=oa and get the more recent unofficial rele

Re: License / Registration key enabled software

2006-09-28 Thread Steve Holden
Sybren Stuvel wrote: > Steve Holden enlightened us with: > >>And you guarantee that the contents of the smartcard is only used by >>one user at a time by building a licensing system for the >>smartcards? > > > We can never, ever make a 100% guarantee that people won't copy what > you supply them

Re: Help me use my Dual Core CPU!

2006-09-28 Thread Michael
Paul Rubin wrote: > "Michael Sparks" <[EMAIL PROTECTED]> writes: >> > Kamaelia doesn't attempt concurrency at all. Its main idea is to use >> > generators to simulate microthreads. >> >> Regarding Kamaelia, that's not been the case for over a year now. >> >> We've had threaded components as wel

Re: XSLT speed comparisons

2006-09-28 Thread Damian
A, thanks for that, I've been searching the documentation and it only briefly mentions XSLT but it sounds like a half-arsed attempt. -- http://mail.python.org/mailman/listinfo/python-list

Re: preemptive OOP?

2006-09-28 Thread John Salerno
Erik Johnson wrote: > My feeling is that there is no good reason to add the complexity of your > own custom classes if they provide no additional data or behaviour. If you > know you have plans to add your own attributes and/or methods to MyNotebook > soon, there's no harm in doing this now, b

Recursive descent algorithm able to parse Python?

2006-09-28 Thread [EMAIL PROTECTED]
I'm a compiler newbie and curious if Python grammar is able to be parsed by a recursive descent parser or if it requires a more powerful algorithm. Chris -- http://mail.python.org/mailman/listinfo/python-list

Re: XSLT speed comparisons

2006-09-28 Thread Damian
Sorry about the multiple posts folks. I suspect it was the "FasterFox" FireFox extension I installed yesterday tricking me. I had a brief look at libxml(?) on my Ubuntu machine but haven't run it on the server. I'll look into pyrxp Larry. I have to say I'm struggling a little with the discoverab

Re: how do you know if open failed?

2006-09-28 Thread Bruno Desthuilliers
tobiah a écrit : > SpreadTooThin wrote: > >> f = open('myfile.bin', 'rb') >> >> How do I know if there was an error opening my file? >> > try: > open('noexist') > except: > print "Didn't open" > Should be: try: f = open('noexists') except IOError, e: print >> sys.stderr, "

Re: Extra Newby question - Trying to create md5 File Listing

2006-09-28 Thread utabintarbo
Just for S&G's, I offer the following function which will return the md5sum of an arbitrarily large file. Found a while back while surfing def md5sum(fpath): """ function to return the md5sum (128 bit checksum) of the given file The sums are computed as described in RFC 1321. The

Re: Python CTypes translation of (pv != NULL)

2006-09-28 Thread p . lavarre
> Where did you find that? Quoted in full from the gift: Subject: Re: Python CTypes translation of (pv != NULL) Date: Tue, 26 Sep 2006 11:48:52 +0200 Message-ID: <[EMAIL PROTECTED]> http://groups.google.com/group/comp.lang.python/msg/f9f13e731ea3cad7 Cached and pondered just slightly before the

Re: a different question: can you earn a living with *just* python?

2006-09-28 Thread Bruno Desthuilliers
Roy Smith a écrit : > In article <[EMAIL PROTECTED]>, > "Carl J. Van Arsdall" <[EMAIL PROTECTED]> wrote: > > >>>Things like decorators and metaclasses certainly add power, but they add >>>complexity too. It's no longer a simple language. >>> >> >>Well, I think a simple language is a language

Re: preemptive OOP?

2006-09-28 Thread Erik Johnson
> class MyNotebook(wx.Notebook): > def __init__(self, parent): > wx.Notebook.__init__(self, parent) > So my question in general is, is it a good idea to default to an OOP > design like my second example when you aren't even sure you will need > it? I know it won't hurt, and is proba

Re: pythonol

2006-09-28 Thread John Martin
On Wed, 27 Sep 2006 14:41:36 -0700, George Sakkis wrote: > John Martin wrote: > >> 'pythonol' is a program for learning spanish. I think it's a really great >- snip --- > >> -- >> D

Re: Resuming a program's execution after correcting error

2006-09-28 Thread MonkeeSage
Georg Brandl wrote: > As I said before, this can be done by finding out where the error is raised, > what the cause is and by inserting an appropriate try-except-statement in > the code. I could be mistaken, but I *think* the OP is asking how to re-enter the stack at the same point as the exceptio

  1   2   3   >