Re: [Tutor] How can I escape a pound symbol in my script?

2007-07-05 Thread Luke Paireepinart
Rikard Bosnjakovic wrote: > On 7/6/07, Richard Querin <[EMAIL PROTECTED]> wrote: > > >> I'm writing a very simple python script which writes out some >> predefined text to a file (which will later become part of an html >> file). I need to write out a pound sign '#' to the file and I can't >> fi

Re: [Tutor] How can I escape a pound symbol in my script?

2007-07-05 Thread Richard Querin
Thanks for the quick responses guys... I was fooled by Vim and my own inexperience. I had forgotten to escape a preceding quote and the pound symbol was generating a python comment which showed up in syntax highlighting... Grrr. Problem fixed now. [walking away embarrassed...] ;)

Re: [Tutor] How can I escape a pound symbol in my script?

2007-07-05 Thread John Fouhy
On 06/07/07, Richard Querin <[EMAIL PROTECTED]> wrote: > I'm writing a very simple python script which writes out some > predefined text to a file (which will later become part of an html > file). I need to write out a pound sign '#' to the file and I can't > figure out how to escape it. I've tried

Re: [Tutor] How can I escape a pound symbol in my script?

2007-07-05 Thread Rikard Bosnjakovic
On 7/6/07, Richard Querin <[EMAIL PROTECTED]> wrote: > I'm writing a very simple python script which writes out some > predefined text to a file (which will later become part of an html > file). I need to write out a pound sign '#' to the file and I can't > figure out how to escape it. I've tried

[Tutor] How can I escape a pound symbol in my script?

2007-07-05 Thread Richard Querin
Hi, I'm writing a very simple python script which writes out some predefined text to a file (which will later become part of an html file). I need to write out a pound sign '#' to the file and I can't figure out how to escape it. I've tried '\#' and '\u0023', but neither works. How can I do it? T

Re: [Tutor] (no subject)

2007-07-05 Thread Luke Paireepinart
[snip e-mail] > > Thanks in advance > > Alun Griffiths > > Alun - Please use a relevant subject line next time you start a thread - all these (no subject) e-mails wreak havoc on those of us who have our e-mail clients set up to display e-mails as threads, rather than just sorted by date. Whenev

Re: [Tutor] python and javascript

2007-07-05 Thread Alan Gauld
"Picio" <[EMAIL PROTECTED]> wrote > I know It's a strange question, please don't become mad at me. I'm > currentlu involved in a project where I will use javascript and > python Not so strange. JavaScript is the undoubted king of browser side scripting, Python doesn't really play in that arena

Re: [Tutor] Fastest way to iterate through a file

2007-07-05 Thread Alan Gauld
"elis aeris" <[EMAIL PROTECTED]> >I need some of a something to be imported into python Maybe. > these are the functions I need, anyway know anything that might do > any of > the following? Assuming you are still talking about Windows XP... > suppose the class' name is autowindow: What kind

[Tutor] python and javascript

2007-07-05 Thread Picio
Hello, I'd like to have some advice about a good mailing list about javascript. I'm asking here because I'd like to have both python and javascript people on the same mailing list. My idea is that some of you participates also in other mailing lists and maybe some of those are about javascript: kno

Re: [Tutor] Fastest way to iterate through a file

2007-07-05 Thread elis aeris
I need some of a something to be imported into python these are the functions I need, anyway know anything that might do any of the following? Eg: suppose the class' name is autowindow: autowindow.gainfocus(handle) put the window of that handle into focus. import autowindow autowindow.im

Re: [Tutor] help with translating a c function to a python function

2007-07-05 Thread Alan Gauld
"shawn bright" <[EMAIL PROTECTED]> wrote > oh, here is what i have so far, but is not giving me the right > values > > def crc16(data): > crc_hi = 0xff > crc_lo = 0xff > for x in data: > crc_index = crc_hi ^ x So far so good.. > crc_hi = crc_lo ^ (crc_hi |

Re: [Tutor] UTF-8 title() string method

2007-07-05 Thread Jon Crump
On Thu, 5 Jul 2007, Kent Johnson wrote: >> First, don't confuse unicode and utf-8. > > Too late ;-) already pitifully confused. > This is a good place to start correcting that: > http://www.joelonsoftware.com/articles/Unicode.html Thanks for this, it's just what I needed! > if s is your utf-8 s

Re: [Tutor] UTF-8 title() string method

2007-07-05 Thread Kent Johnson
Jon Crump wrote: > On Wed, 4 Jul 2007, Kent Johnson wrote: >> First, don't confuse unicode and utf-8. > > Too late ;-) already pitifully confused. This is a good place to start correcting that: http://www.joelonsoftware.com/articles/Unicode.html >> Second, convert the string to unicode and then

Re: [Tutor] help with translating a c function to a python function

2007-07-05 Thread shawn bright
Thanks Alan, so do you think my translation is close? i do not know a lick of c. Nope, not one line. thanks shawn On 7/5/07, Alan Gauld <[EMAIL PROTECTED]> wrote: > > "shawn bright" <[EMAIL PROTECTED]> wrote > while (usDataLen––) > { > uIndex = uchCRCHi ^ *puchMsgg++ ; > u

Re: [Tutor] help with translating a c function to a python function

2007-07-05 Thread Alan Gauld
"shawn bright" <[EMAIL PROTECTED]> wrote while (usDataLen––) { uIndex = uchCRCHi ^ *puchMsgg++ ; uchCRCHi = uchCRCLo ^ auchCRCHi[uIndex} ; uchCRCLo = auchCRCLo[uIndex] ; } return (uchCRCHi << 8 | uchCRCLo) ; } > this part ' auchCRCHi[uIndex}; > it looks

Re: [Tutor] help with translating a c function to a python function

2007-07-05 Thread shawn bright
oh, here is what i have so far, but is not giving me the right values def crc16(data): crc_hi = 0xff crc_lo = 0xff for x in data: crc_index = crc_hi ^ x crc_hi = crc_lo ^ (crc_hi | crc_index) crc_lo = crc_lo | crc_index return (crc_hi << 8 | c

Re: [Tutor] Guidance on a Begginer Project.

2007-07-05 Thread Alan Gauld
"Tony Noyeaux" <[EMAIL PROTECTED]> wrote > ...could see upto 81 different outcomes 9x9So over all there would > be 90 total outcomes listed in a table. I'd probably go for a set of nested dictionaries (or maybe just lists) and data drive the code. Thus the code becomes fairly trivial and the comp

[Tutor] help with translating a c function to a python function

2007-07-05 Thread shawn bright
hello all, i have a c function from some modbus documentation that i need to translate into python. it looks like this: unsigned short CRC16(puchMsg, usDataLen) unsigned char *puchMsg ; unsigned short usDataLen ; { unsigned char uchCRCHi = 0xFF ; unsigned char uchCRCLo = 0xFF ; unsi

Re: [Tutor] lambda: print('x') raises SyntaxError?

2007-07-05 Thread wesley chun
On 7/5/07, Kent Johnson <[EMAIL PROTECTED]> wrote: > wc yeee wrote: > > Hi. Is there a reason the code below raises a syntax error? It's > > probably something silly on my part, but I can't figure it out: > > > > > > >>> b = lambda: print('bar') > > File "", line 1 > > b = lambda: print('bar

[Tutor] Guidance on a Begginer Project.

2007-07-05 Thread Tony Noyeaux
Taking on a pet project to teach myself some things and hone some amateur skills.Wondering if you could help point me in the right direction and assist me with some technical points as i get stuck.I have a basic idea of how i would do this,... but i'm not sure whether it is the best way. So ...

Re: [Tutor] lambda: print('x') raises SyntaxError?

2007-07-05 Thread Kent Johnson
wc yeee wrote: > Hi. Is there a reason the code below raises a syntax error? It's > probably something silly on my part, but I can't figure it out: > > > >>> b = lambda: print('bar') > File "", line 1 > b = lambda: print('bar') > ^ > SyntaxError: invalid synta

Re: [Tutor] From C to Python

2007-07-05 Thread Kent Johnson
Alan Gauld wrote: > "Dhruva Kulkarni" <[EMAIL PROTECTED]> wrote >> Also, i couldn't find the keywords for data encapsulation >> ( private protected in c++ ).. > > More seriously, much of the data protection used in C++ is > due to the contraints of using a static, strictly typed data model. > Once

[Tutor] lambda: print('x') raises SyntaxError?

2007-07-05 Thread wc yeee
Hi. Is there a reason the code below raises a syntax error? It's probably something silly on my part, but I can't figure it out: b = lambda: print('bar') File "", line 1 b = lambda: print('bar') ^ SyntaxError: invalid syntax This code seems to work fine, so I

Re: [Tutor] From C to Python

2007-07-05 Thread Alan Gauld
"Dhruva Kulkarni" <[EMAIL PROTECTED]> wrote > Ok, i get the idea about the referencing, but i got some (;-)) > doubts : Many C/C++ programs find the transition a bit scary at first because they are giving up control of the low level details. But the truth is that in higher level languages like

Re: [Tutor] Help search files

2007-07-05 Thread Alan Gauld
"Alejandro Decchi" <[EMAIL PROTECTED]> wrote > Yes i am a newbie in web design but i understand the concept of CGI. OK, I'll ignore that aspect for now. > My problem is that I do not know how to do a search based in binary > files.For example a user conect to my webpage and dicide to search > w

[Tutor] Fwd: Re: From C to Python

2007-07-05 Thread Dhruva Kulkarni
Dhruva Kulkarni <[EMAIL PROTECTED]> wrote: Date: Thu, 5 Jul 2007 06:12:13 -0700 (PDT) From: Dhruva Kulkarni <[EMAIL PROTECTED]> Subject: Re: [Tutor] From C to Python To: Kent Johnson <[EMAIL PROTECTED]> Thanks for the link, i was afraid it might be something like that :-) Ok, i get the idea abo

Re: [Tutor] From C to Python

2007-07-05 Thread Andreas Kostyrka
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Well, philosophically every object "name" is a pointer to a PyObject on C level. The only difference is, that you cannot do anything but assign these pointers (no pointer arithmetic) and memory is managed automatically. If you want to know what happen

Re: [Tutor] (no subject)

2007-07-05 Thread Kent Johnson
Alun Griffiths wrote: > Hi > > I am trying to build a simple model of a gas field. At the moment I have > these objects: > GasWell represents the behaviour of a gas well > GasFluid represents the thermodynamic behaviour of the gas > GasField represents the field itself > > The G

Re: [Tutor] Help search files

2007-07-05 Thread Alejandro Decchi
Yes i am a newbie in web design but i understand the concept of CGI. My problem is that I do not know how to do a search based in binary files.Forexample a user conect to my webpage and dicide to search windows.iso he write in the textbox and put submit and must appear the result to download the l

Re: [Tutor] From C to Python

2007-07-05 Thread Kent Johnson
Dhruva Kulkarni wrote: > Hi, > I am a C guy wanting to switch to Python for some > application-type-tasks that might be done in Python much quicker and > sooner and smaller than in C...I have fiddled around with Python and > looked through the tutorial, but i'm a bit lost when there are no

[Tutor] (no subject)

2007-07-05 Thread Alun Griffiths
Hi I am trying to build a simple model of a gas field. At the moment I have these objects: GasWell represents the behaviour of a gas well GasFluidrepresents the thermodynamic behaviour of the gas GasFieldrepresents the field itself The GasField object defines properties such as

Re: [Tutor] Help search files

2007-07-05 Thread Alan Gauld
"Alejandro Decchi" <[EMAIL PROTECTED]> wrote > Yes I have a debian server runing apache. Can you give me a link? I could give you lots of links but which is most useful will depend on your level of knowledge. I get the impression that you are not experienced in Web development and so may not even

[Tutor] From C to Python

2007-07-05 Thread Dhruva Kulkarni
Hi, I am a C guy wanting to switch to Python for some application-type-tasks that might be done in Python much quicker and sooner and smaller than in C...I have fiddled around with Python and looked through the tutorial, but i'm a bit lost when there are no pointers ( pun intended! ). I coul

Re: [Tutor] Help! Pickle file

2007-07-05 Thread Alan Gauld
"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; > > to create a new pickle file.. > > #!/usr/bin/p

Re: [Tutor] hash

2007-07-05 Thread Alan Gauld
"linda.s" <[EMAIL PROTECTED]> wrote > what is the use of def __hash__(self)? > I can not understand the document. > any example? First, do you understand what a hash is? Do you want an example of writing a hash - see Andreas reply. Or do you want to know when/how to use a hash? As Andreas sa

Re: [Tutor] n.isalnum() is failing

2007-07-05 Thread Alan Gauld
"János Juhász" <[EMAIL PROTECTED]> wrote >> def isLeapYear(y): >> if y % 4 == 0: return True > As it always return True, if y%4 == 0, there is problem with the > exceptions My original function had %400 not %4 so it worked. >> if (y % 4 == 0) and not (y %100 == 0): return True >> else: ret