On 7/5/06, Ismael Garrido <[EMAIL PROTECTED]> wrote:
韩宪平 wrote:
>
> Returns string."""
> return ";".join(["%s=%s" % (k, v) for k, v in params.items()])
>
> Whant ";"means
> %s=%s?
> join?
>
help(items) no matched.
> Where can i find stuff helpful?
"%s" % (param) is called strin
Greetings!
Below is the announcement we've just made this morning to CLP about
our upcoming Python course. Please forward this msg to anyone whom
you think would be interested or would benefit from Python training
courses. This includes Plone, Zope, Django, TurboGears, and Mailman
groups as well
hi john,
everyone else has posted great replies to your inquiries, so i'll keep
mine brief.
> While the list is kind of slow I thought I'd post a few thoughts on a couple
> of things in Python that bug me.
my 1st comment is that you are not talking about Python alone.
everything you state pertai
> > how about custom constant type?
> > Does python provide?
> No. Python tries to be as "light" as possible. There is a convention
> amongst Python programmers to use upper case names to represent
> constants, e.g. RED = 3.
another aspect of Python numbers that make them "constant" is that all
nu
> You need to step back a bit and get a better understanding of
> variables
> and functions and how to use them. You are trying to run before you
> can walk.
>:
> You need to sit down and work through which variables you need
> and which functions of urllib you need.
>
> I suspect you only need
> I'm trying to call an executable program in Python. I did the following, but
> it doesn't work. Any help is appreciated.
>
> os.system('C:\Program Files\EPANET2\epanet2d.exe
> C:\simulation test\Network3_1.inp C:\simulationtest\Network3_1.out')
try putting an "r" in front of the string, i.e. o
i agree with everyone above, kent, alan, roel... in fact, i have do a
doubletake everytime i write code like this and have to look things up
and/or play with some sample code as you all have done, just to make
sure i got it working. (kinda reminds of going back to look at a perl
script i wrote...
> How do I create the equivalent of a Java class in Python? I've been looking
> at the reference, and it's been confusing to me at least.
can you clarify what you are looking for? do you want to create a
class using Python, create the equivalent of a Java class using Python
via Jython, accessing
> On my computer (Win2K) Python puts the current working directory in
> sys.path. (I'm not sure this happens on Linux.)
yes it does, on any unix-flavored system (Linux, FreeBSD, MacOS X,
Solaris, etc.).
since we're on the topic, there is another attribute in the sys
module, sys.modules that shows
> Thanks all, appears it is the newline character which was causing me
> grief. For some reason I still have to do a readlines on the open file
> at this stage, but I can muck about with that to figure it out.
that is surprising... i would be interested in hearing what problems
you are encounter
> >> For short Python scripts I usually allow the runtime to close the file.
> >> For longer programs and anything written in Jython (which has different
> >> garbage collection behaviour) I usually use an explicit close().
> >
> > i'm still not comfortable without doing my own explicit close(), es
>> HostFile = open("hosts.txt", 'r')
>> for item in [x.strip() for x in HostFile]:
>> :
>>
>>Why is this better when the file is large? It still creates a list with
all lines in it.
yup, that's why i mention this fact below while giving the genex solution.
> > Why not simply:
> >
> > for
> Been trying to understand why the following doesn't work:
>
> HostFile = open("hosts.txt", 'r')
> host = HostFile.readlines()
>
> for item in host:
> print "Connecting to device",item
> tn = telnetlib.Telnet(item)
>:
> File "c:\gideon\python24\lib\telnetlib.py", line 225, in ope
> > "Beginning Python: From Novice to Professional", by
> > Magnus Lie Hetland
>
> There's also, on-line, Dive Into Python by Mark Pilgrim, often
> recommended as a good intro book
both of these are very good books, but the target audience is slightly
different, as is for "Core Python" -- 2nd ed
*** 50% DISCOUNT to STUDENTS/TEACHERS ***
Dear fellow list members,
Below is the announcement we've just made this morning about our
upcoming advanced Python course, May 17-19, 2006. This advanced course
will be offered again in Nov 2006. In Aug 2006, we will have another
intensive introduction
> > prefix = os.path.commonprefix(filter( bool, lines ))
that is an interesting and yes, not very optimal way of saving the set
of non-blank lines. the commonprefix() function takes a list of
pathnames and returns the longest prefix that all strings have in
common, presumably for disk filena
we are all happy to help. it is really good that you were able to get
it working so fast! also, if you want to do any kind of pattern
matching with * or ?, then check out the "glob" module.
merci! "le livre" does not look that good from here... it is a mess
and i have to clean it up before givi
> f=open("~/.myapp.conf","r") # but it returns a IOError: [Errno 2] No such
> file or directory:
>
> How can I do to access this file whatever the user is ?
use os.path.expanduser(path)
http://www.python.org/doc/2.4.3/lib/module-os.path.html
hope this helps!
-- wesley
- - - - - - - - - - - -
> > > I read this week on this forum about a kind of Python video in its
> > > website. Which view is that, and where could I find it?
> >
> > It's a video with gushing praise over Python, made in the style of a Monty
> > Python skit.
>
> On a similar line, I've recently discovered "podcasts".
>
hi patricia,
it would be really helpful to see an example of 'result' before and
after the call to calc_numbers() as well as the code for calc_numbers
if possible.
this will likely reveal the problem that you are having.
thanks,
-wesley
On 4/12/06, Patricia <[EMAIL PROTECTED]> wrote:
> Hi,
>
>
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
> I have missed protected method/variables in Python. How do you declare
> methods/variables used only by a class and their derived classes?
hi Ktalà,
welcome to Python! you missed "protection" in OOP with Python bceause
there are no such declarations in Python!
1) there is a privacy *hint*, wh
hi srini,
i don't know what your system configuration was like for the
installation, but from what i saw in your post (below), it just seems
like /usr/local/pgsql/bin was not in your path since it looks like
"sh" could not find the pg_config command, not Python (which choked
afterwards).
anyway,
> >I tried to install pygresql: version: 3.8, it failed
> >throwing exception : Exception: pg_config tool is not
> >available.
> >
> >I gave another try on google and Postgres site and
> >found Pypgsql, PoPy and psycopg1.
>
> I think that psycopg is generally considered the preferred
> package.
a
> How can we remove one file inside of a zip archive?
>
> import zipfile
> ziparchive = zipfile.ZipFile('test.odt', 'r')
> xmldata = ziparchive.read('content.xml')
> ziparchive.close <--- ADD "( )" HERE TOO
Sophon,
You can remove any number of files from a ZIP fil
> ... this seems to me to be the kind of query where
> you could legitimately post to the main Python
> newsgroup / mailing list and/or to some Mac-specific
> one, if there is such a thing.
... and there is:
http://mail.python.org/mailman/listinfo/pythonmac-sig
cheers,
-- wesley
- - - - - - - -
> I would like to write an app for Linux/Unix
> that fetches a gzipped or bzipped file from a remote server by http or ftp.
> The file will be downloaded to a temporary directory, unzipped and its
> contents copied to specific directory. If the process has gone well, the
> files in the temporary di
*** 50% DISCOUNT for STUDENTS / TEACHERS ***
For those of you who already know Python or other languages but are
learning Python, WE are giving 4 more Python training courses (held
near the San Francisco airport) for the remainder of this year.
Please forward this message to anyone else you know
be the cause - ypou aren't acting like the shell does.
>
> But aws I say thats just a guess based on a quick scim of your port.
>
> Alan G.
>
> - Original Message -
> From: "w chun" <[EMAIL PROTECTED]>
> To:
> Sent: Sunday, March 12, 2006 3:37 A
ok, while we're on the subject, i thought i should ask a question for
once(!). it's been awhile since i played with pipes, and i ran into
this problem on the same day as this post!
if i'm in the shell and playing with a 2-way game with the 'tr' command like so:
$ tr '[a-z]' '[A-Z]'
us
US
ca
CA
d
> i wanted to create my own web server, can any body suggest any tutorial,
> by the way i have gone through book Core Python Programing, in this book
> one example is given but it is to abstract, that i am unable to understand
rakesh,
1) based on this thread and responses from various folks,
> Could anyone, please, suggest a "tutorial" about
> Python Mode for XEmacs? I would like to use XEmacs,
> but unfortunately, I didn't find any good
> documentation about using it for programming in Python
i don't know if there really is a 'tutorial'. i assume you've already
found these websites
> You need to tell python that randint is in the random module.
> ie, instead of calling randint(), call random.randint().
now this reminds me of something... and i think i need the help of the
tutors here! :-)
a long time ago, i recall that randint() was deprecated in favor of
randrange(). th
> Perhaps you've seen this already, but since you are wrapping the print
> in a function, I suspect you want the original list to be unmodified.
> Thus, compare:
>
> >>> def sort_print1(a_list):
> a_list.sort()
> print a_list
>
>
> >>> def sort_print2(a_list):
> t = list(a
On 2/18/06, Servando Garcia <[EMAIL PROTECTED]> wrote:
> Hello List
> I am at a complete loss. Here is a recap, just to be clear, I have
> been unable insert into a database using MySQLdb. I can only view the
> database.
servando,
sorry to hear about these problems. it seems highly unlikely
hi mike,
welcome to python. :-) your query is quite common amongst beginners,
and i have actually spend some time on this topic in my courses.
On 2/17/06, Michael Broe <[EMAIL PROTECTED]> wrote:
> I think I understand this sorting-a-list 'in place' stuff, and things
> of that kind (reversing fo
on a barely related note, sets (mutable [set] and immutable
[frozenset]) were added to Python beginning in version 2.3... so
don't work too hard on your class! you may want to try something more
interesting like:
write a class which let's you keep track of time and does base 60
(sexagesimal / he
On 1/18/06, Johan Geldenhuys <[EMAIL PROTECTED]> wrote:
>
> Has the book 'Internet programming with Python' (ISBN: 1558514848,
> publisher: M&T Books, 1996) ever been revised or is there a secod editin
> available?
> I don't have it, but I would like this or something simular very much.
>
> Any ide
On 1/16/06, Alan Gauld <[EMAIL PROTECTED]> wrote:
> > Has anyone got an easy way of printing the Python documentation in PDF
> > format. Its all in HTML and is time consuming to print.
>
> You can buy it in paper book form.
> It's a lot cheaper than trying to print the online stuff page by page!
>
On 1/11/06, Kent Johnson <[EMAIL PROTECTED]> wrote:
> Burge Kurt wrote:
> >
> > void get_args(int argc, char* argv[], Argument* args)
> >
> > My first question about the pointers here; how can I convert them to
> > Python?
>
> Python doesn't have pointers in the sense of direct references to
> memo
> hello everyone. i was looking at python docs and i came across this
>
> letter ::=
> lowercase | uppercase
>
> what does ::= mean?
you must be referring to identifiers and keywords page at
http://docs.python.org/ref/identifiers.html
take it as meaning, "may expand to." in other w
On 12/20/05, Richard <[EMAIL PROTECTED]> wrote:
> Afternoon all, My son asked me what books I would like for Christmas
> this year. So what would you recommend?
>
> I am a beginner here.
hi richard,
welcome to the list. are you a beginner to Python (but have
programming experience), a beginner
> what would be the best command to end a program with.
> i have an app that i want to start every day at 6am from cron
> but i want it to shutdown at 4pm
>
> i was going to check by time on every loop
>
> if int(time.strftime(%H)) > 4:
> some
looks good for your 1st program. some improvements that i can think of:
1. notice how you repeat blocks of code? specifically, i mean: (ask a
question, get the answer, validate the answer). since this is all
similar code, it's a great place for you to learn what a loop is.
that way, you only h
> > >>> label = 'this is "quoted"'
> > >>> label.replace('"','\"')
> > 'this is "quoted"'
> > ## This works
> > >>> label.replace('"','\'')
> > "this is 'quoted'"
>
>
> What I should have been using is label.replace('"','\\"')
> :-) Nevermind.
hold on a second pardner! :-) what were you t
> It has been great for 11ish months, now all my mail is classed as
> spam & junked :(
dave,
i'm a little surprised by this. if your code has been working for
almost a year and suddently breaks, that can only be explained by 1 or
2 things:
1. your code was modified
2. the server was modified
(
> I wrote my first script (ever) in Python.
> :
> The second one is more python specific I guess. The programs prints
> the "Exiting" string on exit one time for every action I do. Which
> means that if I add 4 users, I'll see 4 time exiting printed. If I add
> 2 users and delete 1 us
On 12/6/05, Alan Gauld <[EMAIL PROTECTED]> wrote:
> Lots of good stuff from Wes snipped...
> > (a side note here: that only mutable objects have methods.)
>
> But this is not quite true. Strings are immutable and have lots
> of methods and even tuples and plain integers have methods
oh POO. i *
On 12/5/05, Kent Johnson <[EMAIL PROTECTED]> wrote:
>
> You have to change how you think about variables. In Python, a variable
> is not a storage location into which values are put, it is a reference
> to an object - a name given to an object. Assignment binds a name to a
> value.
>
> When you cal
> dir(sys)
> help(sys)
to further elaborate, dir() will tell you what it has, and help() will
dump pretty-printed doc strings for you.
good luck!
-- wesley
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"Core Python Programming", Prentice Hall, (c)2006,2001
http://corepython.com
> if __name__ == '__main__':
> global x
> x = 1
> t = T()
> t.p()
as alan mentioned, it's all about namespaces. the "global x" you have
in the above piece of code doesn't do anything (because you're already
or still in the global [name]space).
you're getting the
> - ->: \d+/?\d*
> - ->
> - ->ie 1 or more digits followed by 0 or 1 slashes followed by 0 or more
> digits.
this looks like it'll also accept invalid data, such as "1/" ... i
think there's some more tweaking involved to get it so that if there's
a '/', there is at least one digit afterwards.
-
On 10/26/05, nephish <[EMAIL PROTECTED]> wrote:
> Yeah, cool. i am just starting this part.
> i am glad i started with python.
> thanks for the help
if your app is willing to tolerate errors/crashes, then i would take
alan's advice and just letting the errors happen, as opposed to being
so carefu
On 10/27/05, Matt Williams <[EMAIL PROTECTED]> wrote:
> At the moment, I have something like:
>
> def __init__ (self, a, b, c):
> if type(a) == type("a")
> then.
> elif type(a) == type(["a"])
> then
>
> I'm sure there must be a better way to do this
On 10/26/05, Joseph Quigley <[EMAIL PROTECTED]> wrote:
> I'm back to my IRC client. I accidentally found the thread module...
> What will i do to receive and send at the same time via console?
>
> or:
> Should I forget the idea of a console and start learning GUI which
> will
> do
> i am writing some (for me) pretty complicated stuff for work that
> really needs to work.
> i have looked at exception handling...
> and i am using some try / except statements.
> the problem is, that even though my script does not crash, i dont know
> the exact error.
>
On 10/22/05, Jacob S. <[EMAIL PROTECTED]> wrote:
> >> def nameCheck(self, value):
> >> > import re
> >> > tempREG = re.match('.*:.*',value)
> >> > return str(tempREG) != 'None'
>
> This could be written better.
>
> def nameCheck(self, value):
> tempREG = re.match('.*:.
On 10/21/05, Kent Johnson <[EMAIL PROTECTED]> wrote:
> Ed Singleton wrote:
> > A quick tip for the Windows command line.
> >
> > Ctrl-C, Ctrl-A etc don't work, neither does right-clicking
> > (menu-click). However, right-clicking does work on the blue title
> > bar.
>
> If you turn on Quick Edit (
On 10/20/05, Suri Chitti <[EMAIL PROTECTED]> wrote:
>
> If I have a directory /u01/qa/logs and the logs has a number of children
> directories and I want to remove everything in logs and logs itself, is
> there a single method or command to do that? I want to avoid recursively
> removing the files
On 10/20/05, Dan Klose <[EMAIL PROTECTED]> wrote:
>
> I usually use perl but fancy a bit of a change so have started playing
> with python.
congrats! :-)
> using perl to open a file or directory I usually use:
> open(FILE, $file) or die "Error: $!\n";
>
> The $! is a perl variable that holds an
On 10/19/05, bob <[EMAIL PROTECTED]> wrote:
> At 02:12 PM 10/19/2005, CPIM Ronin wrote:
> >I know that one should use IDLE or a choosen editor for any substantial
> >Python coding! However, if one happens to have written some interesting
> >doodlings on the regular command line interface (under Wi
On 10/18/05, Kent Johnson <[EMAIL PROTECTED]> wrote:
> David Stotijn wrote:
> > Hi,
> >
> > I'm planning on buying a book to help me learn Python. Some of the books
> > I'm considering are a few years old and based on an older version of
> > Python (e.g. 2.3).
> > Is it wise to buy a book based on
dave,
you should be able to start PythonWin in one of 2 ways:
1) Start menu -> Programs -> Python 2.4 -> PythonWin
or
2) C:\Python24\Lib\site-packages\pythonwin\Pythonwin.exe
hope this helps!
-- wesley
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"Core Python Programming", Pre
On 10/16/05, Danny Yoo <[EMAIL PROTECTED]> wrote:
On Sat, 15 Oct 2005, Dave Shea wrote:> Python installed without a complaint. However, when I fire up IDLE,> there is an hour glass shown for a couple of seconds, then nothing else> happens. When I fire up Python (command line) no problem, the DOS bo
On 10/15/05, Andy Dani <[EMAIL PROTECTED]> wrote:
>When I python from /usr/loca/Python-2.4.1/bin, it does launch the
interpreter but with an traceback error saying there is some conflict
with "import readline" line on pythonrc.py file located somewhere in
/etc/ directory. Is there any harm If I com
On 10/14/05, Shi Mu <[EMAIL PROTECTED]> wrote:
I found the code for class "now". I got confused by two things:First, how did the former code I posted know to import tis module of "Now";Second. what does "\" mean following "self.year
,"Thanks a lot!class now: def __str__(self):return ti
On Fri, 14 Oct 2005, Luke Jordan wrote:> I'm trying to have functions to create, edit and store dictionaries
> within a class. i 2nd danny's motion: make your dictionary an instance attribute (unique to that instance) rather than a class attribute (shared amongst all instances), and 2ndly, don't
combining the best of both worlds of nick using a faster list comp and brett using os.path.splitext():>>> files = ['DSC1.JPG', 'DSC2.JPG', 'DSC3.JPG']>>> newFiles = [os.path.splitext
(f)[0] for f in files]>>> print newFiles['DSC1', 'DSC2', 'DSC3']cheers,-- wesley- - - - - -
On 10/13/05, Nick Lunt <[EMAIL PROTECTED]> wrote:
> I'm really confused on the issue how to create windows, forms, etc. in> Python & can't find any manual for that.> Could you possibly advise me smth useful?this has come up quite a bit recently on the list.
I would recommend that you go herehttp://
On 10/12/05, Pujo Aji <[EMAIL PROTECTED]> wrote:
> I have code like this:
>
> def f(x,y):
> return math.sin(x*y) + 8 * x
>
> def main():
> n = 2000
> a = zeros((n,n), Float)
> xcoor = arange(0,1,1/float(n))
> ycoor = arange(0,1,1/float(n))
>
> for i in range(n):
> fo
On 10/12/05, Terry Carroll <[EMAIL PROTECTED]> wrote:
On Wed, 12 Oct 2005, Alan Gauld wrote:> However I have to be honest and say that building GUIs in VB ... is a> lot easier than in Python IMHO.But, man, VB as a language and library set is horrible; and pointlessly
horrible, in many cases.The bes
On 10/12/05, Ertl, John <[EMAIL PROTECTED]> wrote:
You can do most system type stuff in Python and it makes it much easier.import globjpgList = glob.glob("*.jpg") # the glob allows you to use wild cards in thesearchjpgCount = len(jpgList)This gives you a list of all files that end in .jpg. You can
On 10/12/05, enas khalil <[EMAIL PROTECTED]> wrote:
>
> and got the following error :
> Traceback (most recent call last):
> File "F:\MSC first Chapters\error correct.py", line 19, in -toplevel-
> tagger.train(tagged_txt_token)
> File
> "C:\Python24\Lib\site-packages\nltk\tagger\__init__.py
73 matches
Mail list logo