For anyone who was following this, here is the finished, non floating
point, program, after all the kind advice received has been incorporated
into it (hopefully I have the leap year logic right...):
# *** (7) MAIN BODY -- The Buck Starts Here! ***
def isLeapYear(y):
if y % 4 ==
Terry [EMAIL PROTECTED] wrote
def isLeapYear(y):
if y % 4 == 0:
if y % 100 == 0 and y % 400 == 1:
answer = False
return answer
answer = True
return answer
answer = False
return answer
Not quite. y%400 == 1 will only be true for years
Hello Every One,
I create a list of coordinates of 2 lines.
X11,Y11 X12,Y12 as starting and ending of one line.
X21,Y21 X22, Y22 as starting and ending of the 2nd line.
Now is there any way to calculate the deflection angle between the two
lines? Will any modules be required other than Python
I just finish to right a script to teach ESL. I will be using as vocabulary
Basic English . This was created in 1930 an consist of only 800 words . This
script is very small just two kb. plus the Basic vocabulary.
Is anyone there to help me to compile this file into win32 so could be used in
Lucio Arteaga [EMAIL PROTECTED] wrote
Is anyone there to help me to compile this file into win32
so could be used in PC without having to install python
in each PC using it.
Python is an interpreted language so you always need to
install an interpreter, the only question is whether you
On Tue, Jul 03, 2007 at 06:04:16PM -0700, Terry Carroll wrote:
Has anyone found a silver bullet for ensuring that all the filenames
encountered by os.walk are treated as UTF-8? Thanks.
What happens if you specify the starting directory as a Unicode string,
rather than an ascii string, e.g.,
William O'Higgins Witteman wrote:
for thing in os.walk(u'.'):
instead of:
for thing in os.walk('.'):
This is a good thought, and the crux of the problem. I pull the
starting directories from an XML file which is UTF-8, but by the time it
hits my program, because there are no extended
On Wed, 4 Jul 2007, nitin chandra wrote:
Hello Every One,
I create a list of coordinates of 2 lines.
X11,Y11 X12,Y12 as starting and ending of one line.
X21,Y21 X22, Y22 as starting and ending of the 2nd line.
Now is there any way to calculate the deflection angle between the two
On Wed, Jul 04, 2007 at 11:28:53AM -0400, Kent Johnson wrote:
FWIW, I'm pretty sure you are confusing Unicode strings and UTF-8
strings, they are not the same thing. A Unicode string uses 16 bits to
represent each character. It is a distinct data type from a 'regular'
string. Regular Python
Dear People,
I wondering if any of you lovely people can make a suggestion on a
problem which I have with a n dimensional array.
For example, I've a 3x3 array and I have been mapping an element from 1D
to the one directly above it. 3-12
0 1 2
3 4 5
6 7 8
9 10 11
12 13 14
15 16 17
The problem
Hello Someone can help me how to search file in a directory. I need to do a
form where the user write the word to search and if the file was found the
user must could download the file making click in the link
Sorry my english
thz
Alex
___
Tutor
On Wed, 2007-07-04 at 12:00 -0400, William O'Higgins Witteman wrote:
On Wed, Jul 04, 2007 at 11:28:53AM -0400, Kent Johnson wrote:
FWIW, I'm pretty sure you are confusing Unicode strings and UTF-8
strings, they are not the same thing. A Unicode string uses 16 bits to
represent each
Alejandro Decchi [EMAIL PROTECTED] wrote
form where the user write the word to search
and if the file was found
Do you mean the word is the filename (use glob module)
or the word is inside the file (use os.walk)?
Amnd do you need an exact match or a wild card search.
The latter will use
Andy Cheesman [EMAIL PROTECTED]
The problem which I have is that I now need to rotated alternative
layer
of the arrays but I still need to have the original mapping i.e 3 -
12.
Is your problem how to rotate the array?
Or how to preserve the mapping?
or both?
I don't know offhand how to
The user put the word or the regular expresion in a textbox i need to do
when ther user press the buttom submit call the file for example search.py .
I need to do this search.py file to find the file looking for ther user. If
the file or files are found i want to the user can download the files
Alejandro Decchi [EMAIL PROTECTED] wrote
The user put the word or the regular expresion in a textbox i need
to do
when ther user press the buttom submit call the file for example
search.py .
I need to do this search.py file to find the file looking for ther
user.
Is the word the user
Is the word or part of the word that the user enters in the texbox .And this
word is the name of the file to be found
On 7/4/07, Alan Gauld [EMAIL PROTECTED] wrote:
Alejandro Decchi [EMAIL PROTECTED] wrote
The user put the word or the regular expresion in a textbox i need
to do
when
On Wed, 4 Jul 2007, William O'Higgins Witteman wrote:
It is nonsense to talk about 'recasting' an ascii string as UTF-8; an
ascii string is *already* UTF-8 because the representation of the
characters is identical. OTOH it makes sense to talk about converting an
ascii string to a unicode
Alejandro Decchi [EMAIL PROTECTED] wrote
Is the word or part of the word that the user enters in the texbox .
And this word is the name of the file to be found
Ok, In that case use the glob function in the glob module.
It returns a list of all files that match a pattern:
import glob
files
William O'Higgins Witteman wrote:
The problem is that the Windows filesystem uses UTF-8 as the encoding
for filenames,
That's not what I get. For example, I made a file called Tést.txt and
looked at what os.listdir() gives me. (os.listdir() is what os.walk()
uses to get the file and
perfect but can you give me a link to find a file in a directory.Because i
do not the function to search files in some directory. Can you give an
example :
On 7/4/07, Alan Gauld [EMAIL PROTECTED] wrote:
Alejandro Decchi [EMAIL PROTECTED] wrote
Is the word or part of the word that the user
Just set the current directory to the one you want to search using
os.chdir(myPath)
or pass a full path to glob:
glob.glob(/some/path/to/search/*.txt)
HTH,
Alan G.
Alejandro Decchi [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
perfect but can you give me a link to find a file
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
Well, first that sounds somehow like a homework assignment, so only some
hints:
a) work out the underlying math. Consider all special edge cases.
b) I'm not completely sure what you need, but a feeling in the stomach
tells me that you might need the
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
You forgot the uncertainty of 1000% :)
Actually, Python is relativly easy to learn, but I've known people that
were trained by the Arbeitsamt (government employment office), which
never, even after months could predict the output of programs like:
Andy Cheesman wrote:
Dear People,
I wondering if any of you lovely people can make a suggestion on a
problem which I have with a n dimensional array.
For example, I've a 3x3 array
What mechanism (module?) are you using to store the array? Or are you
asking us for a recommendation?
and I
Terry Carroll wrote:
I'm pretty iffy on this stuff myself, but as I see it, you basically have
three kinds of things here.
First, an ascii string:
s = 'abc'
In hex, this is 616263; 61 for 'a'; 62 for 'b', 63 for 'c'.
Second, a unicode string:
u = u'abc'
I can't say what
On Wed, Jul 04, 2007 at 02:47:45PM -0400, Kent Johnson wrote:
encode() really wants a unicode string not a byte string. If you call
encode() on a byte string, the string is first converted to unicode
using the default encoding (usually ascii), then converted with the
given encoding.
Aha!
Ok but i have this form:
head
meta http-equiv=Content-Type content=text/html; charset=iso-8859-1 /
titleDocumento sin tiacute;tulo/title
/head
body
form id=form1 name=form1 method=post action=/cgi-bin/search.py
labelstrong search/strong
input type=text name=textfield align=center /
/label
Thanks Alan,
I managed to get totally confused by the different definitions of
calculating a leap year. The book (Core Python)
described the exercise thus:
Modulus. Determine whether a given year is a leap year, using the
following formula: a leap year is one that is divisible by four, but
not
Terry, thanks.
Sadly, I'm still missing something.
I've tried all the aliases in locale.py, most return
locale.Error: unsupported locale setting
one that doesn't is:
locale.setlocale(locale.LC_ALL, ('fr_fr'))
'fr_fr'
but if I set it thus it returns:
Angoul?äMe, Angoumois.
I'm running
William O'Higgins Witteman wrote:
On Wed, Jul 04, 2007 at 02:47:45PM -0400, Kent Johnson wrote:
encode() really wants a unicode string not a byte string. If you call
encode() on a byte string, the string is first converted to unicode
using the default encoding (usually ascii), then
Jon Crump wrote:
Dear All,
I have some utf-8 unicode text with lines like this:
ANVERS-LE-HOMONT, Maine.
ANGOULÊME, Angoumois.
ANDELY (le Petit), Normandie.
which I'm using as-is in this line of code:
place.append(line.strip())
What I would prefer would be something like this:
Terry Carroll wrote:
I think setting the locale is the trick:
s1 = open(text.txt).readline()
print s1
ANGOUL.ME, Angoumois.
print s1.title()
Angoul.Me, Angoumois.
import locale
locale.setlocale(locale.LC_ALL,('french'))
'French_France.1252'
print s1.title()
Angoul.me, Angoumois.
I
what is the use of def __hash__(self)?
I can not understand the document.
any example? thanks,
Linda
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
Hello there all,
Does anyone know where i can find a function that does an 8 bit Cyclical
Redundancy Check.
I need it to verify data, and i need to be able to create one given an 12
byte message. Does anyone know much about doing this in python ?
thanks
wait, sorry, thats 16 bits total, a low byte and a high byte.
If that makes more sense
thanks
On 7/4/07, shawn bright [EMAIL PROTECTED] wrote:
Hello there all,
Does anyone know where i can find a function that does an 8 bit Cyclical
Redundancy Check.
I need it to verify data, and i need to
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
Simple, defining __hash__ on a class allows you to supply a hash value
for instances of your class.
[EMAIL PROTECTED]:~ cat /tmp/hash.py
class X:
def __hash__(self):
print HASH CALLED
return 123
print hash(X())
[EMAIL
Alejandro Decchi [EMAIL PROTECTED] wrote
Ok but i have this form:
body
form id=form1 name=form1 method=post
action=/cgi-bin/search.py
OK, You didn't make it clear that you meant a CGI program,
I was assuming you meant a GUI program. That adds a whole
heap of extra complexity. A lot depends
On Wed, 4 Jul 2007, Kent Johnson wrote:
Terry Carroll wrote:
Now, superficially, s and e8 are equal, because for plain old ascii
characters (which is all I've used in this example), UTF-8 is equivalent
to ascii. And they compare the same:
s == e8
True
They are equal in every
Terry Carroll wrote:
I'm just saying that UTF-8 encodes ascii characters to themselves; but
UTF-8 is not the same as ascii.
I think we're ultimately saying the same thing; to merge both our ways of
putting it, I think, is that ascii will map to UTF-8 identically; but
UTF-8 may map back or
Yes I have a debian server runing apache. Can you give me a link ? Because i
do not how to make the search and list the files found to download
On 7/4/07, Alan Gauld [EMAIL PROTECTED] wrote:
Alejandro Decchi [EMAIL PROTECTED] wrote
Ok but i have this form:
body
form id=form1 name=form1
This may sound silly, but when writing a program where there is a pickle file,
how does that get included into the entire program? For instance;
to create a new pickle file..
#!/usr/bin/python
# Filename: pickling.py
import cPickle as p
On 05/07/07, Sara Johnson [EMAIL PROTECTED] wrote:
This may sound silly, but when writing a program where there is a pickle
file, how does that get included into the entire program? For instance;
Hi Sara,
You create pickles with pickle.dump and you read them with pickle.load.
For example:
Hi Terry
According to the Gregorian calendar, which is the civil calendar in use
today, years evenly divisible by 4 are leap years, with the exception of
centurial years that are not evenly divisible by 400.
def isLeapYear(y):
if y % 4 == 0: return True
As it always return True, if y%4 ==
44 matches
Mail list logo