On Mon, 3 Jan 2005, Brian van den Broek wrote:
> >> (Aside: one nonobvious example where copying can be avoided is in
> >> Conway's Game of Life: when we calculate what cells live and die in
> >> the next generation, we can actually use the 'Command' design pattern
> >> to avoid making a tempor
Patric,
> How do you go about setting up a new application?
Thats a great question, and I hope we get a few responses.
> For example, suppose I need a script that will collect order
information
> for a set of items ona page. Its output will go to a mail program
so the
> artist can be notified.
> Okay here comes the next question.
>
> In that class, I have 3 functions. Actually, one of them calls the
two
> others.
You have 3 methods, functions and methods are similar but different!
If you think of them asthe same thing you will probably get
confused by OOP later on!
> However when I cal
> It seems that to do a good job of dumping the data, I need to tell
it
> what this class looks like.
>
> Are there alternatives? Does the pickle format really not provide a
> way to inspect the data without the class definitions?
I suspect that loading the file into a good text editror like vim
Danny Yoo wrote:
On Sun, 2 Jan 2005, Dave S wrote:
My matrix 'self.data' consists of a list of 110 items, each item is a
dictionary of 250 keys, each key holds two lists, one of four items, one
of 12 items.
Hi Dave,
Hmmm... what kind of data is being copied here? Python's data structures
a
Alan Gauld wrote:
I needed to copy this matrix to 'self.old_data', so I have been
using
.deepcopy(), which works OK but is SLOW (12+ secs)
Are you sure you need to copy it./ A simple reassignment should work
and then reconstruct the structure using fresh lists/dictionary etc.
That
Hi,
My question is sort of on the difficult side, but I promise I'm a newb
;) So maybe it isn't..
Frederick Lundh himself gave me this chunk of code..and I can't get it
to work. I was hoping someone could spot the error.
The goal is to extract a png image file from a binary simcity 4 file.
#imp
See comments inline...
Bill Burns wrote:
One problem I ran into was sorting my lists. The dictionary I initially came
up with contained a pipe size designation in this format: 1/2", 3/4", 1", etc.
This format is the standard way to write pipe sizes (at least in the US
anyway). When I sorted the dat
> # if header != "\211PNG\r\n\032\n":
> # raise IOError("not a valid PNG file")
> # outfile.write(header)
>
> It returns the IO error when I try it on this and other files:
> http://simcitysphere.com/peachville.sc4
If you are sure the file is OK then it looks like the signature
definit
Danny Yoo wrote:
(Aside: one nonobvious example where copying can be avoided is in
Conway's Game of Life: when we calculate what cells live and die in
the next generation, we can actually use the 'Command' design pattern
to avoid making a temporary copy of the world. We can talk about
this in mor
Looking at your data, the header is at offset 0x60, not 0x50. If I use
infile.seek(0x60)
it works fine.
Kent
Aaron Elbaz wrote:
Hi,
My question is sort of on the difficult side, but I promise I'm a newb
;) So maybe it isn't..
Frederick Lundh himself gave me this chunk of code..and I can't get it
Patric,
I am a strong proponent of
- incremental development
- unit testing and test-first (or at least test-concurrent) programming
- Don't Repeat Yourself and merciless refactoring
I look for a small piece of a problem, or a simplification of the problem, and write some code. I
write unit tests
Patrick Hall wrote:
Hi Dave,
I have a list consisting of about 250 items, I need to know if a
particular item is in the list. I know this is better suited to a
dictionary but thats not the way it ended up ;-)
I could do a for loop to scan the list & compare each one, but I have a
suspission that
Alan Gauld wrote:
You have 3 methods, functions and methods are similar but different!
If you think of them asthe same thing you will probably get
confused by OOP later on!
[Bernard]
I'm already confused! Seriously, I never done oop before, so even the
Python tutorial examples are extremely confus
Bill:
Could you have the "LineEdit#" be your sortable field? If each # after the "LineEdit" prefix were the same length, then you could easily sort on it.
Bob
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
I have written my first cgi script :-
The .html code is :-
Friends CGI Demo (Static Screen)
Friends list for:New User
Enter your name>
How many friends do you have ?
0
10
25
50
100
The python code is :-
#!/usr/bin/env python
import cgi
reshtml = '''Content-Type: text/html\n
Friends CGI Demo (
It sounds like maybe you are opening the HTML directly from the filesystem? You have to install the
HTML and CGI into a web server and access them through the server. The details for this will depend
on the web server.
Kent
David Holland wrote:
I have written my first cgi script :-
The .html cod
David Holland wrote:
I have written my first cgi script :-
The .html code is :-
Friends CGI Demo (Static Screen)
Friends list for:New User
Enter your name>
How many friends do you have ?
0
10
25
50
100
The python code is :-
#!/usr/bin/env python
import cgi
reshtml = '''Content-Type: text/html\
> I'm already confused! Seriously, I never done oop before, so even
the
> Python tutorial examples are extremely confusing to me atm.
Which tutor are you using? If its the standard Python tutor then its
not really for beginners to OOP, you might be better looking at some
of the more basic tutors s
Alan Gauld, Segunda 03 Janeiro 2005 17:23, wrote:
> http://www.cetus-liks.org
Just a correction on the URL: http://www.cetus-links.org/
--
Godoy. <[EMAIL PROTECTED]>
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo
I would like to be able
to take an integer, break it down into individual items in a list, and then put
them back together. I know how to do this last part thanks to Orri Ganel and
Guillermo Fernandex, but what about taking the integer apart?
Sorry if the questions
have incredibly obvious
On Mon, 3 Jan 2005 17:17:36 -0500, kilovh <[EMAIL PROTECTED]> wrote:
>
> I would like to be able to take an integer, break it down into individual
> items in a list, and then put them back together. I know how to do this last
> part thanks to Orri Ganel and Guillermo Fernandex, but what about tak
kilovh said unto the world upon 2005-01-03 17:17:
I would like to be able to take an integer, break it down into
individual items in a list, and then put them back together. I know
how to do this last part thanks to Orri Ganel and Guillermo
Fernandex, but what about taking the integer apart?
Sorry
On Mon, 03 Jan 2005 17:41:49 -0500, Brian van den Broek
<[EMAIL PROTECTED]> wrote:
> .>>> an_int_as_string_list = list(an_int_as_string)
> .>>> print an_int_as_string_list
> ['4', '2']
*Smacks head with palm* Of course, you're right . . . no need to go
into ' '.join(str(x)).split() . . . Python's
Hello,
In perl, I create variables of fairly involved text using here
documents. For example,
$msg = <<"EOF";
a bunch of text here.
...
EOF
Is there an equivalent method in python? I usually use this method
when creating help messages for scripts -- put all the text into a
variable and the
On Mon, Jan 03, 2005, Michael Powe wrote:
>Hello,
>
>In perl, I create variables of fairly involved text using here
>documents. For example,
>
>$msg = <<"EOF";
> a bunch of text here.
> ...
>EOF
>
>Is there an equivalent method in python? I usually use this method
>when creating help messages f
Alan Gauld wrote:
Which tutor are you using? If its the standard Python tutor then its
not really for beginners to OOP,
Yes, I was talking about the one that comes with Python. Now I
understand why I couldn't figure much of it!
you might be better looking at some
of the more basic tutors such as
There was a detailed thread on this recently either here
or on usenet group comp.lang.python...
The bottom line was to use string formatting and triple
quoted strings...
msg = '''
A very long string that overspills
onto multiple lines and includes
my name which is %{name}s
and a number which is m
Oops, those should have been () not {}
> msg = '''
> A very long string that overspills
> onto multiple lines and includes
> my name which is %(name)s
> and a number which is my age: %(age)d
> '''
>
> print msg % vars()
Sorry folks, I really should try these things *before*
I hit the send button.
Alan Gauld, Segunda 03 Janeiro 2005 21:56, wrote:
> Oops, those should have been () not {}
I always do the same mistake ;-) Using "{}" seems more intuitive to me.
--
Godoy. <[EMAIL PROTECTED]>
___
Tutor maillist - Tutor@python.org
http://mai
On Mon, Jan 03, 2005 at 11:54:06PM -, Alan Gauld wrote:
> There was a detailed thread on this recently either here
> or on usenet group comp.lang.python...
I checked the archives for this list but didn't see anything. I'll
try the ng. Thanks.
> The bottom line was to use string formatting
On Mon, Jan 03, 2005 at 10:04:18PM -0200, Jorge Luiz Godoy Filho wrote:
> Alan Gauld, Segunda 03 Janeiro 2005 21:56, wrote:
>
> > Oops, those should have been () not {}
>
> I always do the same mistake ;-) Using "{}" seems more intuitive to me.
perhaps because of ${var} shell syntax? ;-)
mp
I'd like to thank everyone who posted on this thread. I was reading a Korn
shell manual the other day and could not figure out what a "here" document
was. I'm going to take another run at it with this conversation in mind!
Sometimes I can't see the path until I know where it goes.
John Purser
[Kent]
> This is actually a common approach to sorting a list in Python - add enough
> fields to the list so it sorts the way you want, then filter out the fields
> you don't need any more. It even has a name, it's called Decorate - Sort -
> Undecorate. In your case the 'decorate' step is built-in
Hi Alan...
> Thats a great question, and I hope we get a few responses.
Me too!
Thank you for taking the time to reply.
Your response is far more complex than my original example, but its very
illustrative.
Not so much in what to do, but how to think about doing it, and that was my
goal.
Hello Kent...
> I am a strong proponent of
> - incremental development
> - unit testing and test-first (or at least test-concurrent)
> programming - Don't Repeat Yourself and merciless refactoring
I see we have similarities. I purely hate having to rewrite something I've
already done once to sa
On Monday 03 January 2005 8:35 am, Bob Gibson wrote:
> Bill:
>
> Could you have the "LineEdit#" be your sortable field? If each # after
> the "LineEdit" prefix were the same length, then you could easily sort on
> it.
Bob,
Using your suggestion, I did a little test on a modified version of my
ï
I have writen a code to do the process you need.
And It is not only suitable for integers, but also decimals and
negatives! The main method is type conversion functions of Python as
float(), str() and so on. I wish it will give you some
illumination.
Juan Shen
#!/usr/loca
> [Bill]
> I've seen list comprehensions, but I didn't understand how they worked.
> Since I understand how my function works, it's not so hard to figure out
> what your doing with this list comp. I guess the brackets ([]) signify a
list.
> Then the for loop is placed on the right-hand side and the
39 matches
Mail list logo