Tim Michelsen wrote:
> What is the state of the art in storing and parsing configuraions in
> python programs?
It is pretty common to have a configuration module that is imported
wherever the configuration is needed. This is simple but it is
essentially global state and shares some of the disad
Tim Michelsen wrote:
> Hello,
> how can I suppress the decimal places for (only those) numbers whos
> decimal places are zero (0)?
I don't know how to do this with just string formatting but I think
('%.4f' % n).rstrip('.0')
will do what you want.
Kent
___
Hi all,
This is a serious newbie question. I started this morning. I need to do two
simple things (simple on a PC anyway), and I would like to ask the group if
it is even possible on a Mac before I go through learning Python.
I am a partner in an online training company. All training is del
> Yes, thats the way I'd recommend.
>> Is there a more decent and elegant way?
I don't know. I was just asking how other programmers achive this
efficiently.
> Another option is to have the config settiongs in a normal
> Python module and just import it. That is less appealing if
> the config fi
Hello,
how can I suppress the decimal places for (only those) numbers whos
decimal places are zero (0)?
Example:
CODE
In [1]: m = 2.0
In [2]: n = 2.56789080
In [3]: n_format = '%.4f' %n
In [4]: n_format
Out[4]: '2.5679'
In [5]: m_format = '%.4f' %m
In [6]: m_format
Out[6]: '2.00
"Tim Michelsen" <[EMAIL PROTECTED]> wrote
> But I would like to modularize my code and separate the GUI code
> from
> the functional code that provides the calculation operations. This
> will
> help to expand the functionality at a later stage. I want to achieve
> this through splitting the code
Robert Kirkpatrick wrote:
> Hi All,
>
> Just wondering if there are any basic conventions for including code
> snippets that are for testing / debugging only?
>
> For example, you could set a boolean variable called DEBUG, then have
> snippets of code like:
>
> if DEBUG:
> do stuff
> else:
>
Hello,
I am building a simple GUI for a calculation program. I am using config
files (*.cfg) and reading them in with ConfigParser. This works well
because I have nearly all code in 1 text file.
But I would like to modularize my code and separate the GUI code from
the functional code that provid
At 01:39 PM 4/14/2008, Kent Johnson wrote:
Dick Moores wrote:
def sigDigits(n):
"""
Strips any real decimal (as string) to just its
significant digits,
then returns its length, the number of significant
digits.
Examples: "-345" -> "345" ->
3;
"3.000" -> "3000" -> 4
"0.0001
Does the % operator always respect locale or should one use
locale.format() instead?
Are there guidelines where one should use one string formatting
technique vs. another?
Thanks!
Malcolm
___
Tutor maillist - Tutor@python.org
http://mail.python.org/ma
Dick Moores wrote:
> def sigDigits(n):
> """
> Strips any real decimal (as string) to just its significant digits,
> then returns its length, the number of significant digits.
> Examples: "-345" -> "345" -> 3;
> "3.000" -> "3000" -> 4
> "0.0001234" -> "1234" -> 4;
> "10.
At 12:04 PM 4/14/2008, Kent Johnson wrote:
Malcolm Greene wrote:
> What is the Pythonic way to remove specific chars from a string?
The
> .translate( table[, deletechars]) method seems the most
'politically
> correct' and also the most complicated.
Most 'correct' and also by far the fastest. This
"Malcolm Greene" <[EMAIL PROTECTED]> wrote
> What is the Pythonic way to remove specific chars from a string? The
> .translate( table[, deletechars]) method seems the most 'politically
> correct' and also the most complicated.
Assuming you have lots of different characters and not just
one to re
"Malcolm Greene" <[EMAIL PROTECTED]> wrote in
> Background: I have a long multi-line string with expressions
> delimited
> with '<(' and ')>' markers. I would like to extract these substrings
> and
> process them in a loop.
>
> I know how to do this task with regular expressions, but I'm always
Malcolm Greene wrote:
> What is the Pythonic way to remove specific chars from a string? The
> .translate( table[, deletechars]) method seems the most 'politically
> correct' and also the most complicated.
Most 'correct' and also by far the fastest. This recipe makes it a bit
easier to use:
http:
Malcolm Greene wrote:
> Suggestions on the best way to extract delimited substrings strings from
> a larger string?
>
> Background: I have a long multi-line string with expressions delimited
> with '<(' and ')>' markers. I would like to extract these substrings and
> process them in a loop.
> Wha
"Brain Stormer" <[EMAIL PROTECTED]> wrote
>I have a python program which works fine when run using idle but I
>would
> like call the program from the terminal.
>
> python test.py -i inputfile -o outputfile
Easier to use file redirection:
python test.py < inputfile > outputfile
The -i flag in
"Jordan Greenberg" <[EMAIL PROTECTED]> wrote
> > What is a good IDE [for Python] that has Python tools for:
> >
> > library management,
> > code completion,
> > debugging,
> > documentation,
> > help
Depending on what he wants in the way of "Library Management"
then Pythonwin will give him all o
"Ashish Sharma" <[EMAIL PROTECTED]> wrote
> I want to find the font style,Font size written in webpage without
> looking into source code.
Do you mean you need to find the actual font used in the
browser regardless of the settings in the HTML/CSS source?
On Windows you can probably do that by
I used the optparse module since that is exactly what I wanted. Here is my
code:
import sys
from optparse import OptionParser
import os
parser = OptionParser()
parser.add_option("-i", "--input", dest="infile",
help="input FILE to convert", metavar="FILE")
parser.add_option("-o", "--output", dest
What is the Pythonic way to remove specific chars from a string? The
.translate( table[, deletechars]) method seems the most 'politically
correct' and also the most complicated.
My ideas:
1. For each char to be removed, do a .replace( char_to_delete, '' )
2. Do a .split( str_of_chars_to_delete )
Suggestions on the best way to extract delimited substrings strings from
a larger string?
Background: I have a long multi-line string with expressions delimited
with '<(' and ')>' markers. I would like to extract these substrings and
process them in a loop.
Because the left and right delimiters a
On Mon, Apr 14, 2008 at 12:55 PM, Brain Stormer <[EMAIL PROTECTED]> wrote:
> I have a python program which works fine when run using idle but I would
> like call the program from the terminal.
>
> python test.py -i inputfile -o outputfile
>
> I tried with raw_input but that only works in idle. Can
> I want to find the font style,Font size written in webpage without looking
> > into source code.
> >
>
your best bet would be your eyes. otherwise python will need to parse the
source code to tell.
___
Tutor maillist - Tutor@python.org
http://mail.p
i think you need to try :
cat input.txt | /usr/bin/python test.py >output.txt
>
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
look at the OptParse module, with this u can easily realize such things.
http://docs.python.org/lib/module-optparse.html
On Mon, Apr 14, 2008 at 12:55:07PM -0400, Brain Stormer wrote:
> I have a python program which works fine when run using idle but I would
> like call the program from the termi
I have a python program which works fine when run using idle but I would
like call the program from the terminal.
python test.py -i inputfile -o outputfile
I tried with raw_input but that only works in idle. Can this be achieved?
Thanks
___
Tutor maill
bhaaluu wrote:
> A (mainly Java) programmer on a LUG mailing list asks:
>
> What is a good IDE [for Python] that has Python tools for:
>
> library management,
> code completion,
> debugging,
> documentation,
> help
>
> Since I'm not familiar with Java at all, I'm not sure how many
> of
>
> Message: 1
> Date: Mon, 14 Apr 2008 01:31:41 -0700
> From: "Dinesh B Vadhia" <[EMAIL PROTECTED]>
> Subject: [Tutor] encode unicode strings from pysqlite
> To:
> Message-ID: <[EMAIL PROTECTED]>
> Content-Type: text/plain; charset="iso-8859-1"
>
> Here is a program that SELECT's from a pysqli
A (mainly Java) programmer on a LUG mailing list asks:
What is a good IDE [for Python] that has Python tools for:
library management,
code completion,
debugging,
documentation,
help
Since I'm not familiar with Java at all, I'm not sure how many
of the things he is asking for, are even relevant f
Ashish Sharma wrote:
> Hi ,
>
> I want to find the font style,Font size written in webpage without
> looking into source code.
Do you mean you don't want to look at the HTML/CSS for the page? If not,
I guess you will have to somehow query the browser. Tools for that will
be specific to the brow
beautiful soup would do it. It's still looking into the source, though.
On Mon, Apr 14, 2008 at 7:02 AM, Ashish Sharma
<[EMAIL PROTECTED]> wrote:
> Hi ,
>
> I want to find the font style,Font size written in webpage without
> looking into source code.
>
> Can Any one tell if there is API avalab
Hi ,
I want to find the font style,Font size written in webpage without
looking into source code.
Can Any one tell if there is API avalable for this in python .
Thanks in Advance.
Ashish Sharma
___
Tutor maillist - Tutor@python.org
http://mail.python
Hi! Kent. The row[0].encode('utf-8') works perfectly within a standalone
program. But didn't work within webpy until I realized that maybe webpy is
storing the row as a dictionary (which it does) and that you have to get the
string by the key (ie. 'fieldB'). That worked and also webpy encodes
Dinesh B Vadhia wrote:
> Here is a program that SELECT's from a pysqlite database table and
> encode's the returned unicode strings:
> query = "SELECT fieldB FROM testDB WHERE fieldB LIKE '%s' LIMIT '%s'"
> %(q, limit)
> for row in cur.execute(query):
Here row is a list containing a single unic
Here is a program that SELECT's from a pysqlite database table and encode's the
returned unicode strings:
import sys
import os
import sqlite3
con = sqlite3.connect("testDB.db")
cur = con.cursor()
a = u'99 Cycling Swords'
b = a.encode('utf-8')
print b
q = '%wor%'
limit = 25
query = "SELECT fiel
"Que Prime" <[EMAIL PROTECTED]> wrote
> This is what I came up with after writing it out and reading the
> corresponding functions. I feel I'm close but something is still
> awry.
You need to give us more information.
What is still awry? Do you get any errors or is it not
copyng all files? Or
line.strip()
for line in file: => line will contain '\n' at the end of the string.
Andreas
Am Montag, den 14.04.2008, 00:08 -0700 schrieb Que Prime:
>
> This is what I came up with after writing it out and reading the
> corresponding functions. I feel I'm close but something is still
> awry.
>
This is what I came up with after writing it out and reading the
corresponding functions. I feel I'm close but something is still awry.
#file copy based on input file containing filenames to be copied
##
import os
import shutil
os.chdir('c:\\test')
infile = open("in
39 matches
Mail list logo