all_types:
Storage {'type': 'childcare', 'id': 1, 'created':
datetime.datetime(2006, 7, 26, 15, 18, 34, 887436)}
Storage {'type': 'household', 'id': 2, 'created':
datetime.datetime(2006, 7, 26, 15, 18, 34, 887436)}
.
Storage {'type': 'knews', 'id': 10, 'created':
The current specifications for the function are:
def incr(mult,z,zlim,mpylist):
# mult is a vector of exponents for the multipliers in mpylist.
# z is a positive odd integer.
# zlim is the upper bound critical value for the sum of (
mpylist[k][0] *
mpylist[k][1] )
Just to clarify what
CCing back to the list
You don't need to initialise Entry, the for loop does that for you.
just a habit- I've always initialized my vars up front.
so I know they are initialized.
Fair enough, good practice for other languages certainly.
BTW Why not just put all this stuff in the body of the
On 09/08/06, Alan Gauld [EMAIL PROTECTED] wrote:
all_types:
Storage {'type': 'childcare', 'id': 1, 'created':
datetime.datetime(2006, 7, 26, 15, 18, 34, 887436)}
Storage {'type': 'household', 'id': 2, 'created':
datetime.datetime(2006, 7, 26, 15, 18, 34, 887436)}
.
Storage
On 09/08/06, Alan Gauld [EMAIL PROTECTED] wrote:
all_types:
Storage {'type': 'childcare', 'id': 1, 'created':
datetime.datetime(2006, 7, 26, 15, 18, 34, 887436)}
how do i search for a particular string say teststring in this
list
I think what he wants is:
if 'teststring' in
On 09/08/06, Alan Gauld [EMAIL PROTECTED] wrote:
But type is still not accessible as an attribute.
It looked to me like he wanted a list of dictionaries
in which case it wouyld be:
if teststring in [s['type'] for s in all_types]
Err, that is what I meant :-)
--
John.
Hi all,
I have problem with import statement.
supposed that I have two files in different folders : modules/myfile.py
and translate/factory.py.
the folders modules and translate are in the same level, so if I want to
import factory.py into myfile.py, how can I do?
I have already done in
if teststring in [s['type'] for s in all_types]:print 'contained' else:print 'notcontained'this workedthanks a lot guyspyTutor rocksAlan Gauld alan.ga [EMAIL PROTECTED] wrote: On 09/08/06, Alan Gauld <[EMAIL PROTECTED]> wrote: all_types:datetime.datetime(2006, 7, 26, 15, 18, 34,
What is the best way to construct an email in python and also attach a html filethe html file to be attached is not on disk, but should be dynamically constructed in the python scriptthanks a lot
Stay in the know. Pulse on the new Yahoo.com. Check it out.
doesTypeExist=filter(lambda x: typeofstring in x.type, all_types)if 'teststring' in [s.type for s in all_types]this works which is better in terms of speed???for+in or filter+lambdathanks a lotAlan Gauld [EMAIL PROTECTED] wrote: On 09/08/06, Alan Gauld <[EMAIL PROTECTED]> wrote: all_types:
Hi
I know that this was in the list in the last days but i deleted it by
mistake. How to use global variables? Or perhaps you could point me to
another solution. I'm converting a packup app that i made to a gui
driven app. The console app was very straight forward and didn't use any
own
doesTypeExist=filter(lambda x: typeofstring in x.type, all_types)
if 'teststring' in [s.type for s in all_types]
this works which is better in terms of speed???
These do two different things.
The first returns a list of all_types entries that match
The second returns true or false if *any*
the folders modules and translate are in the same level, so if I
want to
import factory.py into myfile.py, how can I do?
You need to make your folders into packages.
Its fairly simple, you basically create an init.py file
But its worth reading about packages in the docs
Come back here ifv you
From: Alan Gauld
Date: 08/09/06 03:30:28
To: Kermit Rose; tutor@python.org
Subject: Re: [Tutor] Exercise in writing a python function.
The current specifications for the function are:
def incr(mult,z,zlim,mpylist):
# mult is a vector of exponents for the multipliers in mpylist.
Message: 2
Date: Wed, 9 Aug 2006 16:04:27 +1200
From: John Fouhy [EMAIL PROTECTED]
Subject: Re: [Tutor] Exercise in writing a python function.
To: Tutor mailing list tutor@python.org
Hi Kermit,
Your basic data structure is a list (actually, several related lists),
which you work your way
could someone explain to me how the import function works?
tom
_
The new Windows Live Toolbar helps you guard against viruses
http://toolbar.live.com/?mkt=en-gb
___
Tutor maillist -
Thanks to John,
I've written tenative code for the incr routine.
Now to test and possibly debug it.
Here is the routine. It's very short.
#
#
# def incr(mult,zlim,mpylist):
# # mult is a vector of exponents for the multipliers in mpylist.
# # z is the integer to be factored
# # zlim
On Wed, 9 Aug 2006, Kermit Rose wrote:
I've written tenative code for the incr routine.
Now to test and possibly debug it.
Just as a note: it's usually a much better idea to write your test cases
first, even before writing any code. It'll give you a better idea of what
you want your
On Wed, 9 Aug 2006, linda.s wrote:
Is that possible to open two Tkinter from one python shell?
It is possible to open more Tkinter toplevel windows. Is this what you
are asking for? See:
http://www.pythonware.com/library/tkinter/introduction/toplevel.htm
If we build a new Toplevel,
On Tue, 8 Aug 2006, Tom Wilson wrote:
could someone explain to me how the import function works?
Hi Tom,
Take a look at:
http://www.python.org/doc/tut/node8.html
and see if that helps; if not, come back and please feel free to ask more
questions about it. In a short summary: import
I confused things by my mistake in the specifications.
The criterion for exiting the outer loop is that
mpylist[0][1] * mult[0] + mpylist[1][1] * mult[1] + mpylist[2][1] *
mult[2]
+ . . .
be zlim.
Can you try rewriting the spec correctly, because I'm still not
sure I understand it? Are
From: Danny Yoo
Date: 08/09/06 11:01:14
To: Kermit Rose
Cc: tutor@python.org
Subject: Re: [Tutor] programming exercise in Python
On Wed, 9 Aug 2006, Kermit Rose wrote:
I've written tenative code for the incr routine.
Now to test and possibly debug it.
Just as a note:
Linda,
Is that possible to open two Tkinter from one python shell?
Tkinter is a python module. You can't really open a Tkinter,
you can only import the module. What you can do is write
a Tkinter application with multiple windows.
You can have as many Tkinter applications running as
you like
Tom,
could someone explain to me how the import function works?
Which tutorial are you reading? They should all describe import.
My tutorial gives the basic description on the Simple sequences
topic and then much more info in the Modules Functions topic
and again in the Namespaces topic.
# lenmult = len(mult)
This is pretty redundant, it only saves two characters typing,
you might as well do
for k in range(len(mult)):
# for k in range(lenmult):
# mult[k] = mult[k] + 1
# if k == 0:
# if mult[k] == 1:
#mult[k] = 2
The
From: Alan Gauld
Date: 08/09/06 12:53:59
To: Kermit Rose; tutor@python.org
Subject: Re: [Tutor] programming exercise in Python
# lenmult = len(mult)
This is pretty redundant, it only saves two characters typing,
you might as well do
**
hmm
I had gotten in the habit of
# testsum = 0
# if k 0:
# mult[k-1] = 0
# for j in range(k,lenmult):
# testsum = testsum + mpylist[j][1] * mult[j]
My brain is bending with this bit! I'm not sure if its right or
not...
for k = 0, checks to see if it may add 1 to mult[0]
for k = 1, sets mult[0] = 0, and checks to see
From: Alan Gauld
Date: 08/09/06 13:52:09
To: Kermit Rose
Cc: tutor@python.org
Subject: Re: [Tutor] programming exercise in Python
# testsum = 0
# if k 0:
# mult[k-1] = 0
# for j in range(k,lenmult):
# testsum = testsum + mpylist[j][1] * mult[j]
My brain is bending with
I had the program generate the test cases for me, and then inspected
them to verify that they were what I desired.
Hi Kermit,
Ah. Try not to do that next time.
It's way too easy to be convinced that some test is working by just
copying the output of the code and looking for reasonable
Here's a script I wrote to email myself the Python Daily webpage as
HTML:
http://dev.metaperl.com/Members/tbrannon/python/code-snippets/script-to-
email-python-daily/
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
it's much more useful to write out the complete test case without
preconceptions, without the aid of the code you're trying to test.
This works because:
* Writing out the test cases first can help in writing the
real function.
Those test cases act as documentation that other
I have a string problem. The following code skips the loop if the string 'app'
is on the banned list ...
self.ban_app_list =
[' ', 'live_dat', 'exact_sl', 'html_str', 'valid_da', 'datacore', 'check_co',
'logger']
if app in self.ban_app_list:
continue
the string 'app' is derived from
On Wednesday 09 August 2006 20:45, dave s wrote:
I have a string problem. The following code skips the loop if the string
'app' is on the banned list ...
self.ban_app_list =
[' ', 'live_dat', 'exact_sl', 'html_str', 'valid_da', 'datacore',
'check_co', 'logger']
if app in self.ban_app_list:
Is there a way to show the ascii values of the string - kind of hexedit
for a string
Try running repr() on the string: it will show an external
programmer-friendly representation that should be easier to read. For
example:
##
msg = 'hello\000world'
print repr(msg)
On Wednesday 09 August 2006 21:11, you wrote:
Is there a way to show the ascii values of the string - kind of hexedit
for a string
Try running repr() on the string: it will show an external
programmer-friendly representation that should be easier to read. For
example:
What techniques should I use to make my code run faster? Always profile before you optimize for speed. You should always optimize for readability first: it's easier to tune readable code than to read 'optimized' code, especially if the optimizations are not effective. Before
Hi Anil,
It looks like you found the info below somewhere, it would be
nice to credit the source and if possible provide a URL - not
least so we can all bookmark it and see if it gets updated
over time?... :-)
Thanks for posting,
Alan G.
- Original Message -
From: anil maran [EMAIL
if I want to import factory.py into myfile.py, how can I do?
You need to make your folders into packages.
Its fairly simple, you basically create an init.py file
But its worth reading about packages in the docs
Come back here ifv you have any questions after that.
The other way would be
http://jaynes.colorado.edu/PythonIdioms.html#idioms_efficientAlan Gauld [EMAIL PROTECTED] wrote: Hi Anil,It looks like you found the info below somewhere, it would benice to credit the source and if possible provide a URL - notleast so we can all bookmark it and see if it gets updatedover time?...
the overall root document of this useful read is:
http://jaynes.colorado.edu/PythonGuidelines.html
-wesley
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
Can someone help Amil? My hands won't allow me to type too long. Thanks!
-- Forwarded message --
Date: Wed, 9 Aug 2006 17:09:19 -0700 (PDT)
From: anil maran [EMAIL PROTECTED]
To: Danny Yoo [EMAIL PROTECTED]
Subject: Re: [Tutor] html file - construct attach send... email python
បានសរសេរ Alan Gauld:
Hi Alan,
the folders modules and translate are in the same level, so if I want to
import factory.py into myfile.py, how can I do?
You need to make your folders into packages.
Its fairly simple, you basically create an init.py file
But its worth reading about packages in
42 matches
Mail list logo