On Jun 5, 8:56 pm, Robert Dailey wrote:
> Is it possible to create an object in Python that will clean itself up
> at function exit? I realize destruction of objects may not occur
> immediately and can be garbage collected, but this functionality would
> still be great to have. Consider the follow
On Jan 2, 7:20 pm, Ben Finney
wrote:
> vk writes:
> > > If there were, I would expect it to conform with PEP 8 (get those
> > > ugly camelCase names outta there :-)
>
> > haha, please forgive me.
> > I'll try and think of some more creative names.
>
> They don't need to be creative; they merely n
On Aug 15, 11:31 am, Ivan Reborin <[EMAIL PROTECTED]> wrote:
> Hello all,
>
> I'm new to python, new as newbies get, so please, don't take wrongly
> if this seems like a stupid or overly simple question.
>
> I'm going through examples in a book I have ("Beginning python", by
> Hetland Marcus) and I
On Aug 13, 2:27 pm, tmallen <[EMAIL PROTECTED]> wrote:
> Here's the code:http://pastebin.com/m21dfcc19
>
> What could be improved? The script feels clumsy, and I have no
> experience refactoring Python code. This will eventually be a GUI FTP
> client. I'm mainly looking for design advice...
Well o
On Aug 13, 7:48 pm, Johnny <[EMAIL PROTECTED]> wrote:
> if I want to fill zeros to the right, what function can help??
> ex:
> '1.23'=>'1.2300'
> but '1.23'.zfill(6)=>'001.23'
>>> '1.23'.ljust(6, '0')
'1.2300'
Sebastian
--
http://mail.python.org/mailman/listinfo/python-list
On Aug 12, 9:49 am, Alexandru Mosoi <[EMAIL PROTECTED]> wrote:
> I'm using python's interpreter's to run various commands (like a
> normal shell). However if sources are modified changes are not
> reflected so I have to restart interpreter. Is there any way to avoid
> restarting this?
>
> example:
On Jul 28, 1:55 am, Lawrence D'Oliveiro <[EMAIL PROTECTED]
central.gen.new_zealand> wrote:
> In message
> <[EMAIL PROTECTED]>,
>
>
>
> [EMAIL PROTECTED] wrote:
> > On Jul 27, 10:55 pm, Lawrence D'Oliveiro <[EMAIL PROTECTED]
> > central.gen.new_zealand> wrote:
> >> In message
> >> <[EMAIL PROTECTED]
On Jul 27, 10:55 pm, Lawrence D'Oliveiro <[EMAIL PROTECTED]
central.gen.new_zealand> wrote:
> In message
> <[EMAIL PROTECTED]>,
>
>
>
> [EMAIL PROTECTED] wrote:
> > On Jul 26, 6:47 pm, Lawrence D'Oliveiro <[EMAIL PROTECTED]
> > central.gen.new_zealand> wrote:
> >> In message
> >> <[EMAIL PROTECTED]
On Jul 26, 6:47 pm, Lawrence D'Oliveiro <[EMAIL PROTECTED]
central.gen.new_zealand> wrote:
> In message
> <[EMAIL PROTECTED]>,
>
>
>
> [EMAIL PROTECTED] wrote:
> > On Jul 24, 5:01 am, Lawrence D'Oliveiro <[EMAIL PROTECTED]
> > central.gen.new_zealand> wrote:
>
> >> In message
> >> <[EMAIL PROTECTED
On Jul 25, 3:38 am, [EMAIL PROTECTED] wrote:
> > By that logic, C++ is not OO. By that logic, Ruby is not OO. By that
> > logic, I know of only one OO language: Java :)
>
> > The fact that a language doesn't force you to do object-oriented
> > programming doesn't mean that it's not object-oriented.
On Jul 24, 5:01 am, Lawrence D'Oliveiro <[EMAIL PROTECTED]
central.gen.new_zealand> wrote:
> In message
> <[EMAIL PROTECTED]>, Jordan
> wrote:
>
> > Except when it comes to Classes. I added some classes to code that had
> > previously just been functions, and you know what I did - or rather,
> > fo
On Jul 23, 4:28 pm, Anthony <[EMAIL PROTECTED]> wrote:
> Hi, I'm a FoxPro programmer, but I want to learn python before it's
> too late. I do a lot of statistical programming, so I import SPSS
> into python. In my opinion, the best features of Visual FoxPro 9.0
> were:
> a) Intellisense (tells yo
On Jul 15, 11:55 pm, Ben Finney <[EMAIL PROTECTED]>
wrote:
> [EMAIL PROTECTED] writes:
> > I just came across this unusual situation where I'd like to modify a
> > string passed to a function
>
> Again: Why? The normal way to do this is to create a new string and
> return that.
>
Yes, usually, bu
On Jul 15, 6:46 pm, Larry Bates <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
> > Hi everyone,
>
> > I've heard that a 'str' object is immutable. But is there *any* way to
> > modify a string's internal value?
>
> > Thanks,
> > Sebastian
>
> Why would you care? Just create a new string (wi
Hi everyone,
I've heard that a 'str' object is immutable. But is there *any* way to
modify a string's internal value?
Thanks,
Sebastian
--
http://mail.python.org/mailman/listinfo/python-list
On Jul 3, 3:59 pm, Ron Garret <[EMAIL PROTECTED]> wrote:
> I'm writing a little HTTP server and need to parse request content that
> is mime-encoded. All the MIME routines in the Python standard library
> seem to have been subsumed into the email package, which makes this
> operation a little awkw
On Jun 30, 11:55 am, [EMAIL PROTECTED] wrote:
> Is there any way to type into a Tkinter frame window?
> I want to use raw_input() within a Tkinter frame.
import sys
import Tkinter
import cStringIO
class GUIInputMgr(Tkinter.Entry):
def __init__(self, parent):
Tkinter.Entry.__init__(se
On Jun 27, 4:05 pm, "Joe P. Cool" <[EMAIL PROTECTED]> wrote:
> If I call os.environ.clear in a python program child processes still
> see the deleted entries. But when I iterate over the keys like so
>
> names = os.environ.keys
> for k in names:
> del os.environ[k]
>
> then the entries are al
On Jun 26, 4:24 am, teh_sAbEr <[EMAIL PROTECTED]> wrote:
> Great! It works properly now but I have one more question, would
> anyone know how to get the changes to take effect immediately? Like
> some sort of Python way to force the desktop to reload? AFAIK the only
> way that'll happen is if I use
On Jun 25, 9:48 pm, teh_sAbEr <[EMAIL PROTECTED]> wrote:
> Hi everybody. I'm trying to write a script that'll change desktop
> wallpaper every time its run. Heres what I've gotten so far:
>
> #random wallpaper changer!
> import _winreg
> from os import walk
> from os.path import exists
> from rando
On Jun 24, 5:36 pm, John Machin <[EMAIL PROTECTED]> wrote:
> On Jun 25, 4:32 am, cirfu <[EMAIL PROTECTED]> wrote:
>
> > if char in "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz":
>
> > cant i write something like:
> > if char in "[A-Za-z]":
>
> You can write that if you want to, but it's eq
On Jun 21, 12:29 pm, Yang Zhang <[EMAIL PROTECTED]> wrote:
> Hi, is there any way to get unbuffered stdout/stderr without relying on
> the -u flag to python or calling .flush() on each print (including
> indirect hacks like replacing sys.stdout with a wrapper that succeeds
> each write() with a flu
Hi,
Just wanted to announce a little project I've just uploaded. It's a
web server written in Python. You can get it at http://code.google.com/p/sws-d/
.
Any suggestions or comments are welcome!
Regards,
Sebastian
--
http://mail.python.org/mailman/listinfo/python-list
On Jun 16, 4:56 pm, [EMAIL PROTECTED] wrote:
> After a couple of weeks studying Python, I already have a few useful
> scripts, including one that downloads 1500 Yahoo stock quotes in 6
> seconds. However, many things are puzzling to me. I keep on seeing
> things like "__main__" in scripts. A more
On Jun 15, 9:37 am, Ben Finney <[EMAIL PROTECTED]>
wrote:
> [EMAIL PROTECTED] writes:
> > I know there must be at least a few very solid answers to this, but,
> > just to hear it from the Pythonistas: Why can't there be several GUI
> > toolkits on the standard library?
>
> Because the Zen of Python
I know there must be at least a few very solid answers to this, but,
just to hear it from the Pythonistas: Why can't there be several GUI
toolkits on the standard library?
--
http://mail.python.org/mailman/listinfo/python-list
On Jun 7, 3:15 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
> On Fri, 06 Jun 2008 23:57:03 -0700, s0suk3 wrote:
> > You can just split the path on `os.sep', which contains the path
> > separator of the platform on which Python is running:
>
&
On Jun 7, 12:55 am, eliben <[EMAIL PROTECTED]> wrote:
> Hello,
>
> os.path.split returns the head and tail of a path, but what if I want
> to have all the components ? I could not find a portable way to do
> this in the standard library, so I've concocted the following
> function. It uses os.path.s
On May 22, 12:49 pm, "Kurt Smith" <[EMAIL PROTECTED]> wrote:
> On Thu, May 22, 2008 at 10:55 AM, duli <[EMAIL PROTECTED]> wrote:
> > Hi:
> > I would like recommendations forbooks(in any language, not
> > necessarily C++, C, python) which have walkthroughs for developing
> > a big software project ?
On May 28, 3:47 am, Matt Nordhoff <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
> > I wanted to ask for ways to test whether a path exists. I usually use
> > os.path.exists(), which does a stat call on the path and returns True
> > if it succeeds, or False if it fails (catches os.error). Bu
I wanted to ask for ways to test whether a path exists. I usually use
os.path.exists(), which does a stat call on the path and returns True
if it succeeds, or False if it fails (catches os.error). But stat
calls don't fail only when a path doesn't exist. I see that, at least
on Windows, the instanc
On May 22, 8:51 am, "A.T.Hofkamp" <[EMAIL PROTECTED]> wrote:
> On 2008-05-22, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> > Hi, I wanted to know how cautious it is to do something like:
>
> > f = file("filename", "rb")
> > f.read()
>
> > for a possibly huge file. When calling f.read(), and not
Hi, I wanted to know how cautious it is to do something like:
f = file("filename", "rb")
f.read()
for a possibly huge file. When calling f.read(), and not doing
anything with the return value, what is Python doing internally? Is it
loading the content of the file into memory (regardless of whethe
On May 21, 10:34 am, Dave Parker <[EMAIL PROTECTED]>
wrote:
> On May 20, 7:05 pm, Collin <[EMAIL PROTECTED]> wrote:
>
> > Personally, FT is a bit meh to me. The way you issue your statements I
> > always think something is wrong, mainly because when I want to define,
> > say, x, in python I'd go:
>
On May 20, 12:22 pm, "John Salerno" <[EMAIL PROTECTED]> wrote:
> "Paul McGuire" <[EMAIL PROTECTED]> wrote in message
>
> news:[EMAIL PROTECTED]
> On May 20, 10:50 am, [EMAIL PROTECTED] wrote:
>
> > def compress(s):
> > return list(set(s))
>
> > That does the trick.
>
> Wow, I just *knew* there had
On May 20, 9:04 am, castironpi <[EMAIL PROTECTED]> wrote:
> On May 20, 5:04 am, Duncan Booth <[EMAIL PROTECTED]> wrote:
>
>
>
> > John Salerno <[EMAIL PROTECTED]> wrote:
> > a = 'this is longer'
> > b = 'this is longer'
> > a == b
> > > True
> > a is b
> > > False
>
> > > In the
On May 20, 11:02 am, "Ahmed, Shakir" <[EMAIL PROTECTED]> wrote:
> I have thousands of records in MS Access database table, which records I
> am fetching using python script. One of the columns having string like
> '8 58-2155-58'
>
> Desired output: '858215558'
>
> I want to remove any spaces betwee
On May 20, 9:58 am, Paul McGuire <[EMAIL PROTECTED]> wrote:
> On May 20, 8:13 am, "John Salerno" <[EMAIL PROTECTED]> wrote:
>
>
>
> > I posted this code last night in response to another thread, and after I
> > posted it I got to wondering if I had misused the list comprehension. Here's
> > the two
On May 19, 10:25 am, "Alan Wright" <[EMAIL PROTECTED]> wrote:
> Hi Folks,
> I am newbie to Python, but have successfully created a simple client and
> server setup, I have one issue though.
>
> I am trying to test a box by sending many TCP conns (WHILE loop) but not
> closing them with a FIN/RST. H
On May 18, 7:25 pm, John Salerno <[EMAIL PROTECTED]> wrote:
> On Sun, 18 May 2008 16:17:55 -0700 (PDT)
>
> Mensanator <[EMAIL PROTECTED]> wrote:
> > I see no need for GUI in any of these applications.
>
> Yeah, I try to find little projects to write in Python that don't involve a
> GUI. It's quick
On May 15, 3:12 pm, RossGK <[EMAIL PROTECTED]> wrote:
> Just getting used to the PyDev environment in eclipse by playing with
> a few simple programs. I'm also using wxPython GUI stuff.
>
> I've noticed though that simple print commands in my code cause a
> "wxPython:stdout/stderr" popup window to
On May 15, 12:07 pm, globalrev <[EMAIL PROTECTED]> wrote:
> On 15 Maj, 19:04, globalrev <[EMAIL PROTECTED]> wrote:
>
> > when i try to write to the file...
>
> > Traceback (most recent call last):
> > File "C:\Python25\myPrograms\netflix\netflix.py", line 10, in
> >
> > d.write('hej du galne
On May 13, 10:24 am, Dave Parker <[EMAIL PROTECTED]>
wrote:
> > The "Flaming Thunder" looks promising, but without being free
> > software, it's unlikely it will create a large developer community,
> > specially considering both free general purpose and scientific
> > programming languages.
>
> Pe
On May 8, 5:25 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> Hi,
>
> i was reading/learning some hello world program in python.
> I think its very simillar to Java/C++/C#. What's different (except
> syntax) ?
>
> what can i do easily with python which is not easy in c++/java !?
>
Are you a
On May 8, 2:14 am, "Florencio Cano" <[EMAIL PROTECTED]> wrote:
> Hi,
> I'm looking for a method of gathering information about the system
> hardware and software installed using Python. I would like to do it in
> UNIX and in Windows. I think that it would be good in Windows to look
> in the registr
On May 6, 12:14 am, "Gabriel Genellina" <[EMAIL PROTECTED]>
wrote:
> (the convention is to use lowercase names for attributes: rawdata instead
> of RawData)
>
But at least put an underscore between the words (raw_data), or, if
you like the OO world, make the subsequent words capitalized
(rawData).
file.truncate(X) will truncate the file to at most X bytes (i.e. leave
the first X bytes of the file and throw away the rest). Is there a way
to throw away, say, the first X bytes of the file, and leave the rest?
(Without opening the same file for reading, reading and processing,
overwriting the fi
On May 4, 6:59 am, Protected <[EMAIL PROTECTED]> wrote:
> On May 4, 12:18 pm, [EMAIL PROTECTED] wrote:
>
>
>
> > On May 4, 5:22 am, Protected <[EMAIL PROTECTED]> wrote:
>
> > > I had previously ran the import line. I prepended it to the example
> > > code I'm trying to run every time but it did not
On May 4, 5:22 am, Protected <[EMAIL PROTECTED]> wrote:
> I had previously ran the import line. I prepended it to the example
> code I'm trying to run every time but it did not help, still nothing
> happens. With or without var before 'root'. I'm pasting the code in
> IDLE and using Windows XP as w
On May 2, 3:26 pm, TkNeo <[EMAIL PROTECTED]> wrote:
> On May 2, 2:49 pm, Jeff <[EMAIL PROTECTED]> wrote:
>
> > The generally used idiom for that is:
>
> > lst = ['a', 'b', 'c']
> > if 'a' in lst:
> > foo = lst.index('a')
>
> Jeff - Gracias !!
>
> I am fairly new to python. Thanks for the example
On Apr 12, 11:11 am, [EMAIL PROTECTED] wrote:
> I should have been more specific about possible fixes.
>
> > > python2.5 -m timeit 'gc.disable();l=[(i,) for i in range(200)]'
>
> > 10 loops, best of 3: 662 msec per loop
>
> > > python2.5 -m timeit 'gc.enable();l=[(i,) for i in range(200)]'
On Apr 29, 2:17 pm, jmDesktop <[EMAIL PROTECTED]> wrote:
> On Apr 29, 2:37 pm, "Jerry Hill" <[EMAIL PROTECTED]> wrote:
>
>
>
> > On Tue, Apr 29, 2008 at 2:14 PM, jmDesktop <[EMAIL PROTECTED]> wrote:
> > > Thanks. That worked on mac. But it does work like I said in
> > > Windows. Don't know why
On Apr 29, 12:46 pm, jmDesktop <[EMAIL PROTECTED]> wrote:
> On Apr 29, 1:16 pm, jmDesktop <[EMAIL PROTECTED]> wrote:
>
>
>
> > Hi, I have this code (learning from Core Python, Chun's book), module
> > named chap2.py.
>
> > class FooClass(object):
> > version=0.1
>
> > def __init__(s
On Apr 28, 4:42 am, Hrvoje Niksic <[EMAIL PROTECTED]> wrote:
> Nick Craig-Wood <[EMAIL PROTECTED]> writes:
> > What you are missing is that if the recv ever returns no bytes at all
> > then the other end has closed the connection. So something like this
> > is the correct thing to write :-
>
> >
On Apr 28, 4:30 am, Nick Craig-Wood <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> > I wanted to ask for standard ways to receive data from a socket stream
> > (with socket.socket.recv()). It's simple when you know the amount of
> > data that you're going to receive,
On Apr 26, 7:25 am, Irmen de Jong <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
> > Until now, I've been
> > doing this little trick:
>
> > data = client.recv(256)
> > new = data
> > while len(new) == 256:
> > new = client.recv(256)
> > data += new
>
> Are you aware that recv() will
On Apr 25, 5:52 pm, Erik Max Francis <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
> > I wanted to ask for standard ways to receive data from a socket stream
> > (with socket.socket.recv()). It's simple when you know the amount of
> > data that you're going to receive, or when you'll receiv
I wanted to ask for standard ways to receive data from a socket stream
(with socket.socket.recv()). It's simple when you know the amount of
data that you're going to receive, or when you'll receive data until
the remote peer closes the connection. But I'm not sure which is the
best way to receive a
On Apr 22, 5:25 am, azrael <[EMAIL PROTECTED]> wrote:
> Hy guys,
> A friend of mine i a proud PERL developer which always keeps making
> jokes on python's cost.
>
> Please give me any arguments to cut him down about his commnets
> like :"keep programing i python. maybe, one day, you will be able to
Sorry, the above post is not complete. This is the rest:
# There should be a for or a while loop around here
try:
name = _winreg.EnumValue(key, index)
except EnvironmentError:
# It raises WindowsError, but the _winreg documentation
# recommends catching EnvironmentError
break
else:
On Apr 19, 6:20 am, hellt <[EMAIL PROTECTED]> wrote:
> HI all, i found winreg module
> fromhttp://www.rutherfurd.net/python/winreg/index.html
> very useful and simple, instead _winreg.
>
> But i have a problem with this module, in its iterable part.
>
> look at the following code
>
> key = Key(HKL
On Apr 17, 12:34 pm, Michael Torrie <[EMAIL PROTECTED]> wrote:
>
> Another thing to consider is that referencing a member of a class or
> instance already *is* a dictionary lookup. It's how python works. Thus
> dictionaries are optimized to be fast. Since strings are immutable,
> python hashes t
On Apr 17, 12:24 pm, Michael Torrie <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
> >
> > There! That's the whole code. I guess the way you suggest is simpler
> > and a bit more intuitive, but I was figuring that the way I suggested
> > it is more stylish.
>
> Umm, doesn't defining all tho
On Apr 17, 12:07 pm, Sion Arrowsmith <[EMAIL PROTECTED]>
wrote:
> <[EMAIL PROTECTED]> wrote:
> >In Python, you usually can use parentheses to split something over
> >several lines. But you can't use parentheses for an assignment of
> >several lines.
>
> Yes you can, you just need an iterable of th
On Apr 17, 11:46 am, Arnaud Delobelle <[EMAIL PROTECTED]> wrote:
>
> Why not do something like:
>
> class RequestHeadersManager:
>
> def __init__(self, string):
> self._fields = {}
> # Populate self.fields with fields defined in 'string'
>
> def __getitem__(self, fieldname):
On Apr 17, 11:44 am, Gary Herron <[EMAIL PROTECTED]> wrote:
> But. *What's the point* of doing it this way.I see 14 variables
> being assigned a value, but I don't see the value, they are getting.
> Reading this bit if code provides no useful information unless I'm
> willing to scan down the
On Apr 17, 10:54 am, [EMAIL PROTECTED] wrote:
> On 17 avr, 17:40, [EMAIL PROTECTED] wrote:
>
> Out of sheer curiosity, why do you need thirty (hand-specified and
> dutifully commented) names to the same constant object if you know
> there will always be only one object?
I'm building a web server.
> Yuck! No way!! If you *want* to make your code that hard to read, I'm
> sure you can find lots of ways to do so, even in Python, but don't
> expect Python to change to help you toward such a dubious goal.
>
Well, my actual code doesn't look like that. Trust me, I like clean
code.
> Seriously,
On Apr 17, 10:10 am, [EMAIL PROTECTED] wrote:
> Thank you Martin and John, for you excellent explanations.
>
> I think I understand the unicode basic principles, what confuses me is the
> usage different applications make out of it.
>
> For example, I got that EN DASH out of a web page which state
I was shocked a while ago when a discovered that in Python you can't
do a multiline assignment
with comments between the lines.
For example, let's say I want to assign a bunch of variables to an
initial, single value. In C or a similar language you would do:
CONSTANT1=
/* This is some constan
On Apr 17, 2:09 am, ragia <[EMAIL PROTECTED]> wrote:
> hi
> i have to match text string char by char to a regular expressions tht
> just allow digits 0-9 if other thing a ppear it shall be replaced with
> space.how can i do that any help?
> so far i have the string and can read it using a for loop
On Apr 14, 9:00 pm, agent E 10 <[EMAIL PROTECTED]> wrote:
>Hi, I'm brand new to programming. Have any suggestions? I'm young.
> Was it a good idea to start with python? I was planning on creating a
> very simple program that asked yes/no questions for a school project.
>
> -Thanks!
Hey! That's
On Apr 16, 3:27 pm, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote:
> Any function can be implemented without recursion, although it isn't
> always easy or fun.
>
> Jean-Paul
Really? I'm curious about that, I can't figure out how that would
work. Could give an example? Say, for example, the typica
On Apr 16, 1:43 pm, [EMAIL PROTECTED] wrote:
> so I’m trying to create a class that inherits from str, but I want to
> run some code on the value on object init. this is what I have:
>
> class Path(str):
> def __init__( self, path ):
> clean = str(path).replace(
I had posted this before but all the spam whipped it out...
I wanted to know if there's any way to create a method that takes a
default parameter, and that parameter's default value is the return
value of another method of the same class. For example:
class A:
def __init__(self):
self
I wanted to know if there's any way to create a method that takes a
default parameter, and that parameter's default value is the return
value of another method of the same class. For example:
class A:
def __init__(self):
self.x = 1
def meth1(self):
return self.x
def m
Hello, I was hoping to get some opinions on a subject. I've been
programming Python for almost two years now. Recently I learned Perl,
but frankly I'm not very comfortable with it. Now I want to move on
two either Java or C++, but I'm not sure which. Which one do you think
is a softer transition fo
77 matches
Mail list logo