>
> I'm trying with this operator, could it possible?
>
> fruit1 = 'apple'
> fruit2 = 'orange'
>
> fruits = fruit1 or fruit2
>
> is 'orange' = fruits ?
Maybe this:
###
fruit1 = 'apple'
fruit2 = 'orange'
fruits = [fruit1, fruit2]
print 'orange' in fruits# prints the boolean result of 'o
Hi,
I'm trying with this operator, could it possible?
fruit1 = 'apple'
fruit2 = 'orange'
fruits = fruit1 or fruit2
is 'orange' = fruits ?
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
Hi,
Today i tested u=unicode(str,'utf-8') and u=str.decode('utf-8'). Then in both
case I used:
if isinstance(u,str):
print "just string"
else:
print "unicode"
the result of both case are "unicode". So it seems u=unicode(str,'utf-8') and
u=str.decode('utf-8') are the same. How about the pr
a colleague demonstrated a problem he had with regular expressions
>>> apppath = os.path.abspath(os.curdir)
>>> apppath
'C:\\napp_and_author_query\\napp_and_author_query\\a b c d'
>>> template = r'\files'
>>> template
'\\files'
>>> re.sub(r'(?i)', apppath, template)
'C:\napp_and_author_query\napp_
Hi Ros,
I placed two new lines of code in your choices 2
and 7. The new lines have comments trailing them.
In choice 7, you forgot to delete the previous
father_son pair (as you had done in choice 5).
Regards,
Charles
###
# list all fathers elif choice ==
"2": p
Hi,
I'm a Python newbie, but I went over the code, and
I think the problem is in choice number 2.
###
for father_son in
father_son:
print father_son###
father_son becomes a string here.
Regards,
Charles B.
- Original Message -
From:
Ros
Dani
I just created a "who's your daddy?" program--one of the challenges in the michael dawson book.
It was working well, and I tested all the different instructions, and then for some reason, it stopped working. Specifically, whenever I enter the name of a father, it tells me it doesn't exist, althoug
define year first
I.E.
year=0
int(year)
or leave the int year out of your code completely - you do not need to
typecast - it is set as an integer in the following line.
Nathan Pinno wrote:
> Hey all,
>
> What's the invalid syntax in the following code? I tried figuring it out
> by myself, a
> What's the invalid syntax in the following code? I tried figuring it out
> by myself, and I couldn't.
>
> The editor highlights the word year in the line:
>
> int year
>
> after I hit okay when this message pops up:
>
> Invalid syntax.
Hi Nathan,
I would believe the editor. *grin*
Python does
Hey
all,
What's the invalid
syntax in the following code? I tried figuring it out by myself, and I
couldn't.
# This program finds
the date of Easter Sunday between the years 1900 & 2099.# By Nathan
Pinno# Inspired by Programming and Problem Solving with Java, 1st ed.,
question 3, page
Dana Robinson wrote:
>
> Have the functions take large numbers of parameters.
>
> or
>
> Create an options class to pass the options around.
>
>
Pythonically, I heard the distinct scream of DICTIONAR in my head.
Hugo
___
Tutor maillist - Tut
Richard Querin wrote:
> My question before I start is whether or not using an XML format for the
> individual file formats is the way to go, and if I have to anticipate
> every little thing in the file formats before hand. I don't want to do
> this, I would rather like to be able to just add an
Hi Alan,
Thank you again. I did not give a try by using
dictionary power. It works now.
Thanks again for tip.
-srini.
dida = {}
for m in nbat:
cols = m.split('\t')
old = cols[0]
dida.setdefault(old,[]).append(cols[1])
lista = ndat.split('\n')
result = []
for i in li
> One of the proble is that, Contig27915_RC is seen
> associated with many XM entries in nbat. However,
> with the above script I could replace only once in
> xta. I could not print Contig27915_RC with many XM_
> guys in nbat. How can this be done.
>
> Finally, this whole process seems to be more
> wxPython, but nothing very complex. I want to write a suite of in-house
> structural engineering design programs for my own purposes.
Sounds emminently pythonic.
> - write each program independently as a standalone structural design app
> - design and write the programs in such a way that in th
Python wrote:
> On Wed, 2006-04-05 at 10:50 -0400, Kent Johnson wrote:
>> Ray Allen wrote:
>>> I would like Python to convert a date returned by MySQL (2006-04-05)
>
> Kent's advice below is of course correct, but I'd bet your variable is
> already a datetime.date (or mx.DateTime.Date with older P
On Wed, 2006-04-05 at 10:50 -0400, Kent Johnson wrote:
> Ray Allen wrote:
> > I would like Python to convert a date returned by MySQL (2006-04-05)
Kent's advice below is of course correct, but I'd bet your variable is
already a datetime.date (or mx.DateTime.Date with older Python
releases). In th
Sorry for the very long email. and I my brain is dead
to create some related generic snippet. Thus, I shrunk
the string and lists into as short as I could.
apologies again.
srini
--- Srinivas Iyyer <[EMAIL PROTECTED]> wrote:
> Dear Tutors,
> I have a huge string and 2 lists. List A consists
>
Dear Tutors,
I have a huge string and 2 lists. List A consists of
tabed elements, where first tab represents entry
somewhere in string(ndat).
ndat has 'Contig27915_RC' and List A [nbat]has
'Contig27915_RC\tXM_945977'. List B [nmlist]has
elements, for instance ['XM_945977\tNM_152513']. Now
my tas
I am planning to write a program (or series of programs) and want some
advice beforehand. I've written a few small programs with Python
and wxPython, but nothing very complex. I want to write a suite of
in-house structural engineering design programs for my own purposes. I want to do the
following:
Oh yeah - you can also simply use Mysql's date_format() function when
you query the database ??
select date_format(column_name,'%d-%b-%Y') as formatted_date from table
where blah;
would output the date as 05-Apr-2006
http://dev.mysql.com/doc/refman/4.1/en/date-and-time-functions.html
Brian
I wrote something similar on my blog some time back..
http://phplogix.com/codefool/?postid=13
This is for converting Apache logfiles to a ISO formatted date for
mysql.. It could easily be reversed, with a little tweaking.. :)
to wit:
def mreplace(s, chararray, newchararray):
for a, b in zip
Ray Allen wrote:
> I would like Python to convert a date returned by MySQL (2006-04-05) to a
> user readable format such as 05-Apr-2006 for display and then to convert it
> back to ISO format for update.
Here's one way:
In [1]: from datetime import date
In [2]: data = '2006-04-05'
Use split()
I would like Python to convert a date returned by MySQL (2006-04-05) to a
user readable format such as 05-Apr-2006 for display and then to convert it
back to ISO format for update. What is the most convenient way of doing
this? I'm struggling to understand the datetime module's functionality.
On Wed, 2006-04-05 at 12:34 +0100, Alan Gauld wrote:
> > Suppose you have a situation where you have a large number of command-line
> > options that you will parse with getopt. You want to keep track of these
> > as you move around in the code and do various things.
> >
> > Is it more Pythonic to:
Keo Sophon wrote:
> On Sunday 02 April 2006 04:47, Kent Johnson wrote:
>> Alan Gauld wrote:
>>> "Keo Sophon" <[EMAIL PROTECTED]> wrote in message
>>> news:[EMAIL PROTECTED]
>>>
Is there anyway to get the content of an XML elements. I am using
xml.dom.
>>> For true XML I think ElemTree (by
w chun wrote:
> On 4/4/06, Kent Johnson <[EMAIL PROTECTED]> wrote:
>> Mike Hansen wrote:
> - you can use __slots__ to restrict arbirtrary creation of
(dynamic)
> instrance attributes
You can do this, but it is generally considered a misuse of
__slots__ and potentially problem
On Wed, April 5, 2006 5:02 pm, Keo Sophon wrote:
> Hi,
>
> How to convert a decimal number to hexadecimal, octal and vice versa?
>>> foo = 2
>>> str(foo) # Integer to string
'2'
>>> oct(15) # Integer to octal
'017'
>>> hex(15) # Integer to hex
'0xf'
>>> int(0xf) # Hex to decimal integer
--
-
On Sunday 02 April 2006 04:47, Kent Johnson wrote:
> Alan Gauld wrote:
> > "Keo Sophon" <[EMAIL PROTECTED]> wrote in message
> > news:[EMAIL PROTECTED]
> >
> >>Is there anyway to get the content of an XML elements. I am using
> >> xml.dom.
> >
> > For true XML I think ElemTree (by Fred Lundh?) is
"Keo Sophon" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> How to convert a decimal number to hexadecimal, octal and vice versa?
The number is stored in binary on the computer so you never convert
the number itself, what you convert is the representation of that number
as a strin
On 4/5/06, Keo Sophon <[EMAIL PROTECTED]> wrote:
>
> how to convert an integer number to string?
Use str(object) to convert an object to a string. For example:
>>> str(42)
'42'
The reverse function is int(x) to convert a string to an integer:
>>> int('42')
42
_
> Thanks for the prompt replies. I have now processed my file with 999
> lines
> and it took seconds. It was beautiful.
Glad it works, a couple of tweaks:
> filename = "a:/calllist.csv"
> filename2 = "c:/calllist.csv"
> import string
> import os
You don't use os or string so don't need to imp
hi,
how to convert an integer number to string?
thanks,
phon
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
Hi,
How to convert a decimal number to hexadecimal, octal and vice versa?
Thanks,
phon
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
> Suppose you have a situation where you have a large number of command-line
> options that you will parse with getopt. You want to keep track of these
> as you move around in the code and do various things.
>
> Is it more Pythonic to:
>
> Have the functions take large numbers of parameters.
>
> C
Hi John,
what do you think about this?
def InplaceReplace(filename):
lines = open(filename, 'r').readlines()
lines = [line.replace(' ', '') for line in lines]
open(filename, 'wt').writelines(lines)
It works well on so small files.
Yours sincerely,
__
Já
On 4/4/06, Kent Johnson <[EMAIL PROTECTED]> wrote:
> Mike Hansen wrote:
> >>> - you can use __slots__ to restrict arbirtrary creation of
> >> (dynamic)
> >>> instrance attributes
> >> You can do this, but it is generally considered a misuse of
> >> __slots__ and potentially problematic.
what speci
John Corry wrote:
> Your advice was spot on. I have enclosed the code that I ended up with.
> Instead of appending it to a list, I just wrote it to another file in the
> corrected format.
A few notes below:
>
>
> filename = "a:/calllist.csv"
> filename2 = "c:/calllist.csv"
> import string
> imp
Dear All,
Thanks for the prompt replies. I have now processed my file with 999 lines
and it took seconds. It was beautiful.
Your advice was spot on. I have enclosed the code that I ended up with.
Instead of appending it to a list, I just wrote it to another file in the
corrected format.
file
Hi!
> I am having difficulty removing white spaces from my file. The file
is
> 999
line = line.replace(' ','')
should do the work
Carlo.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
40 matches
Mail list logo