Re: [Tutor] Floating Confusion

2007-08-23 Thread Alan Gauld
"wormwood_3" <[EMAIL PROTECTED]> wrote 1.1 > 1.1001 > "1.1" is a float type, and apparently it cannot be represented by > binary floating point numbers accurately. > I must admit that I do not understand why this is the case. This isn't just a problem in binary. Consider u

Re: [Tutor] Floating Confusion

2007-08-23 Thread Kent Johnson
Luke Paireepinart wrote: > I've always wondered: > There are numbers in Decimal that can't be represented accurately in > Binary without infinite precision. > But it doesn't go the other way. Rational base-2 numbers are rational > base-10 numbers. I'm supposing this is because base-10 is a hig

Re: [Tutor] A fun puzzle

2007-08-23 Thread Dick Moores
At 07:34 PM 8/22/2007, Kent Johnson wrote: >FWIW here is my fastest solution: > >01 from itertools import chain >02 def compute(): >03 str_=str; int_=int; slice_=slice(None, None, -1) >04 for x in chain(xrange(1, 101, 10), xrange(2, 101, 10), >05 xrange(3, 101, 10), xrange(4, 1

Re: [Tutor] A fun puzzle

2007-08-23 Thread Kent Johnson
Dick Moores wrote: > At 07:34 PM 8/22/2007, Kent Johnson wrote: >> FWIW here is my fastest solution: >> >> 01 from itertools import chain >> 02 def compute(): >> 03 str_=str; int_=int; slice_=slice(None, None, -1) >> 04 for x in chain(xrange(1, 101, 10), xrange(2, 101, 10), >> 05 x

[Tutor] [ANN] Python courses this Fall

2007-08-23 Thread wesley chun
Folks, I'd like to announce my final Python courses for 2007: Need to get up-to-speed with Python as quickly as possible? Come join me, Wesley Chun, author of Prentice-Hall's well-received "Core Python Programming," for another set of courses this Fall in beautiful Northern California! This will b

Re: [Tutor] A fun puzzle

2007-08-23 Thread Dick Moores
At 08:20 AM 8/23/2007, Kent Johnson wrote: >Dick Moores wrote: >>At 07:34 PM 8/22/2007, Kent Johnson wrote: >>>FWIW here is my fastest solution: >>> >>>01 from itertools import chain >>>02 def compute(): >>>03 str_=str; int_=int; slice_=slice(None, None, -1) >>>04 for x in chain(xrange(1,

Re: [Tutor] A fun puzzle

2007-08-23 Thread Kent Johnson
Dick Moores wrote: >> Two reasons. First, looking up a name that is local to a function is >> faster than looking up a global name. To find the value of 'str', >> the interpreter has to look at the module namespace, then the >> built-in namespace. These are each dictionary lookups. Local values

[Tutor] Converting code to string

2007-08-23 Thread Bernard Lebel
Hello, I'm looking for a way to convert Python code into a string. For example, let say I have this function: def myFunc(): print 'hello world' Now in the same module, I'd like to take this function and convert it into a string: """def myFunc(): print 'hello world'\n""" Thanks Bern

Re: [Tutor] Converting code to string

2007-08-23 Thread bhaaluu
Greetings, The following is from: http://www.hetland.org/coding/ ## Self-Printing One-Liner If you run this one-liner at a command prompt, it should print out a copy of itself (write it as one continuous line, without the line break): python -c "x='python -c %sx=%s; print x%%(chr

Re: [Tutor] Converting code to string

2007-08-23 Thread Kent Johnson
Bernard Lebel wrote: > Hello, > > I'm looking for a way to convert Python code into a string. > > For example, let say I have this function: > > def myFunc(): > print 'hello world' > > > Now in the same module, I'd like to take this function and convert it > into a string: > > """def myFu

Re: [Tutor] Converting code to string

2007-08-23 Thread Luke Paireepinart
Bernard Lebel wrote: > Hello, > > I'm looking for a way to convert Python code into a string. > > For example, let say I have this function: > > def myFunc(): > print 'hello world' > > > Now in the same module, I'd like to take this function and convert it > into a string: > > """def myFunc():

Re: [Tutor] Converting code to string

2007-08-23 Thread Alan Gauld
"Bernard Lebel" <[EMAIL PROTECTED]> wrote > I'm looking for a way to convert Python code into a string. Read the file as text? You can find the file by checking the __file__ attribute of a module. > Now in the same module, I'd like to take this function and convert > it > into a string: If its

Re: [Tutor] Converting code to string

2007-08-23 Thread Bernard Lebel
Hi Kent, When try your approach, I get an IOError. >>> import inspect >>> def myFunc(): ... print 'hello world' ... >>> >>> s = inspect.getsource(myFunc) Traceback (most recent call last): File "", line 1, in ? File "C:\Python24\lib\inspect.py", line 552, in getsource lines, lnum = ge

[Tutor] capturing process's status with python

2007-08-23 Thread Flaper87
Hi everybody! i would like to know how can i capture the system process's status with python, i need to know if they are sleeping, zombie or runing. I use Debian lenny, GNU/Linux thanks -- Flavio Percoco Premoli, A.K.A. [Flaper87] http://www.flaper87.com Usuario Linux registrado #436538 Geek b

Re: [Tutor] Converting code to string

2007-08-23 Thread Eric Brunson
Bernard Lebel wrote: > Hi Kent, > > When try your approach, I get an IOError. > > import inspect def myFunc(): > ... print 'hello world' > ... > s = inspect.getsource(myFunc) > Traceback (most recent call last): > File "", line 1, in ? > File

Re: [Tutor] Converting code to string

2007-08-23 Thread Alan Gauld
"Bernard Lebel" <[EMAIL PROTECTED]> wrote > Why? Because I'm using an API (the Softimage|XSI scripting API) > where > I have to create a custom GUI (using that API's GUI toolkit). > > I have to attach a logic callback to a number of widgets that can > change from one execution to the next. Can y

Re: [Tutor] capturing process's status with python

2007-08-23 Thread Eric Brunson
I'm a bit more of a Linux expert than a Python guru, so I don't know if there's a facility in python to do that. However, if you look in /proc, every running process has a directory corresponding to its PID and in that directory is a pseudo-file called "status" that you can get state informat

Re: [Tutor] Table Joins

2007-08-23 Thread Ricardo Aráoz
Terry Carroll wrote: > On Wed, 22 Aug 2007, z machinez wrote: > >> Hi All: >> >> I have the following tables selected from a database: >> >> a1 >> >> a2 >> >> each table are of the same column length, same col names. How do I combine >> or concatenate these tables ? So, I would like to have >> >>

Re: [Tutor] capturing process's status with python

2007-08-23 Thread Alan Gauld
"Flaper87" <[EMAIL PROTECTED]> wrote > i would like to know how can i capture the system process's status > with > python, i need to know if they are sleeping, zombie or runing. The simplest route on Unix may be just to run ps using the subprocess.Popen object or os.popen. You can then parse th

[Tutor] Problem from complex string messing up

2007-08-23 Thread Sebastien
Hi, I have these bunch of html files from which I've stripped presentation with BeautifulSoup (only kept a content div with the bare content). I've received a php template for the new site from the company we work with so I went on taking the same part of my first script that iterates through

[Tutor] HOWTO: adding to sys.path the simplest way.

2007-08-23 Thread Tim Johnson
I have a seperate library directory both on my work station on the the remote servers that I write applications for.. I commonly use sys.path.append('/path/to/mylibraries') in my python code. That code has to be placed in any standalone script that I write. I can also place that path in a system

Re: [Tutor] Problem from complex string messing up

2007-08-23 Thread Kent Johnson
Sebastien wrote: > I used triple quotes """template code""" to avoid problems, but every file > touched by the script end up having a problem and not being able the show the > supposed drop down menu. Now the code the company did for this drop down is > pretty esoteric: > > /*

Re: [Tutor] HOWTO: adding to sys.path the simplest way.

2007-08-23 Thread Kent Johnson
Tim Johnson wrote: > I have a seperate library directory both on my work station on > the the remote servers that I write applications for.. > > I commonly use sys.path.append('/path/to/mylibraries') in my > python code. > > That code has to be placed in any standalone script that I write. > I c

[Tutor] the and command

2007-08-23 Thread max baseman
hello im checking if a number is in all 5 of the other lists and when i use the and command it seems to just be checking if it's in a least one of the others, here is the program it's choppy i needed it for a quick calculation so it's not pretty but it's not long: n2=2 n3=3 n4=4 n5=5 n6=6 n