On Mon, Jun 20, 2011 at 1:26 PM, Chris Angelico wrote:
> > I'd be inclined toward the second solution if I'm writing all the code
> > myself
>
On Mon, Jun 20, 2011 at 3:21 PM, Florencio Cano wrote:
> I'm with Chris, if the config_scripts are going to be implemented in
> Python always, the second
On Sun, Jun 19, 2011 at 11:00 PM, Tim Hanson wrote:
> Using linux and Python 2.6, learning how to work with files from a Windows
> oriented textbook:
>
> This works:
> infile=open('/foo/bar/prog/py_modules/this_is_a_test','r')
>
> This doesn't:
> infile=open('~/prog/py_modules/this_is_a_test','r')
On Mon, 2011-06-20 at 08:14 +0200, Florencio Cano wrote:
> > This works:
> > infile=open('/foo/bar/prog/py_modules/this_is_a_test','r')
> >
> > This doesn't:
> > infile=open('~/prog/py_modules/this_is_a_test','r')
> >
> > Can't I work with files using Unix expressions?
>
> You can use the glob mod
> I'd be inclined toward the second solution if I'm writing all the code
> myself, but very definitely the first if someone else might write one
> of the subscripts (especially so if this is going to be distributed
> widely) - spawning a new process means that the system's isolation of
> processes
> This works:
> infile=open('/foo/bar/prog/py_modules/this_is_a_test','r')
>
> This doesn't:
> infile=open('~/prog/py_modules/this_is_a_test','r')
>
> Can't I work with files using Unix expressions?
You can use the glob module:
http://docs.python.org/library/glob.html#module-glob
--
http://mail.p
Using linux and Python 2.6, learning how to work with files from a Windows
oriented textbook:
This works:
infile=open('/foo/bar/prog/py_modules/this_is_a_test','r')
This doesn't:
infile=open('~/prog/py_modules/this_is_a_test','r')
Can't I work with files using Unix expressions?
--
http://mail.
Steven D'Aprano wrote:
>> and you can achieve php interpolation via locals()
>>
> a = 'b'
> print("%(a)s" % locals())
>> b
>
> You can do that, but when reading code I consider any direct use of
> locals() (and globals() for that matter) to be a code smell:
well you're right, me neither
On Mon, Jun 20, 2011 at 2:13 PM, Stephen Bunn wrote:
> List,
>
> First I'm very new to Python. I usually do this kind of thing with shell
> scripts, however, I'm trying to move to using python primarily so I can
> learn the language.
A worthy cause :)
> ... I have come up with two ways to
> a
List,
First I'm very new to Python. I usually do this kind of thing with shell
scripts, however, I'm trying to move to using python primarily so I can
learn the language. I'm attempting to write a script that will check a
server for various configuration settings and report and/or change based
On Jun 19, 8:52 pm, Chris Kaynor wrote:
> Having a character class (along with possibly player character, non-player
> character, etc), make sense; however you probably want to make stuff like
> health, resources, damage, and any other attributes not be handles by any
> classes or inheritance
On Jun 18, 2011, at 9:26, John Salerno wrote:
> Whew, thanks for all the responses! I will think about it carefully
> and decide on a way. I was leaning toward simply assigning the health,
> resource, etc. variables in the __init__ method, like this:
>
> def __init__(self, name):
>self.name
On Sun, 19 Jun 2011 23:06:36 +0200, Vito 'ZeD' De Tullio wrote:
> well, in python3 you can use dict to format strings
>
print("%(a)s" % {'a':'b'})
> b
It's not just Python 3. That bit of functionality goes back all the way
to Python 1.5, which is the oldest version I have installed.
In Py
On Sun, Jun 19, 2011 at 2:06 PM, Vito 'ZeD' De Tullio
wrote:
> Roy Smith wrote:
>
>> There's something nice about building up strings in-line, as
>> opposed to having to look somewhere to see what's being interpolated.
>> To give a more complex example, consider:
>>
>> print "$scheme://$host:$port
Roy Smith wrote:
> There's something nice about building up strings in-line, as
> opposed to having to look somewhere to see what's being interpolated.
> To give a more complex example, consider:
>
> print "$scheme://$host:$port/$route#$fragment"
>
> That certainly seems easier to me to read tha
On Jun 19, 10:50 am, Lie Ryan wrote:
> On 06/19/11 15:14, rusi wrote:
>
>
>
> > On Jun 19, 9:21 am, Lie Ryan wrote:
> >> On 06/18/11 03:53, Xah Lee wrote:
>
> >>> On Jun 15, 5:43 am, rusi wrote:
> On Jun 15, 5:32 pm, Dotan Cohen wrote:
>
> > Thanks. From testing small movements with my
In article
,
rusi wrote:
> On Jun 19, 8:39 pm, Roy Smith wrote:
>
> > This is one of the (very) few places PHP wins over Python. In PHP, I
> > would write this as
> >
> > print "'$x'"
>
>
> You dont find
>
> >>> print '"%s"' % x
>
> readable? Why?
I didn't say it wasn't readable, I said
On 06/20/11 02:52, Laurent Claessens wrote:
>
>> Popping task off the end of the list is more efficient:
>
>> while task_list:
>> task_list.pop().start()
>
> That's cool. In my case it's better to do
> task_list.pop(0).start
>
> in order to pop the first element.
then you really wanted a q
On 06/20/11 00:32, TheSaint wrote:
> Hello
>
> Trying to pop some key from a dict while is iterating over it will cause an
> exception.
> How I can remove items when the search result is true.
>
> Example:
>
> while len(dict):
>for key in dict.keys():
> if dict[key] is not my_result:
On Jun 19, 8:39 pm, Roy Smith wrote:
> This is one of the (very) few places PHP wins over Python. In PHP, I
> would write this as
>
> print "'$x'"
You dont find
>>> print '"%s"' % x
readable? Why?
--
http://mail.python.org/mailman/listinfo/python-list
On 6/19/2011 12:03 PM, Chris Angelico wrote:
On Mon, Jun 20, 2011 at 1:39 AM, Laurent Claessens wrote:
My problem is that when FileToCopyTask raises an error, the program does not
stop.
In fact when the error is Disk Full, I want to stop the whole program
because I know that the next task will
Popping task off the end of the list is more efficient:
while task_list:
task_list.pop().start()
That's cool. In my case it's better to do
task_list.pop(0).start
in order to pop the first element.
or if the list is static
No, my list is dynamic and is feeded by an other thread (whi
On 6/19/2011 11:53 AM, Roy Smith wrote:
Yet another variation which makes sense if you want to delete most of
the keys would be to copy them to a new dictionary. I'm not sure how
Python handles memory management on dictionaries which shrink.
'Python' does not handle memory management; each im
Le 19/06/2011 18:03, Chris Angelico a écrit :
On Mon, Jun 20, 2011 at 1:39 AM, Laurent Claessens wrote:
My problem is that when FileToCopyTask raises an error, the program does not
stop.
In fact when the error is Disk Full, I want to stop the whole program
because I know that the next task
* 2011-06-19T12:20:32-04:00 * Terry Reedy wrote:
> On 6/19/2011 9:24 AM, Steven D'Aprano wrote:
>> No. Each cell in a Lisp-style linked list has exactly two elements,
>> and in Python are usually implemented as nested tuples:
>>
>> (head, tail) # Annoyingly, this is also known as (car, cdr).
>>
>
On 6/19/2011 11:39 AM, Laurent Claessens wrote:
In the same time I've a thread that read the list and perform the
operations:
def run():
while task_list :
task = task_list[0]
task_list.remove(task)
task.start()
Popping task off the end of the list is more efficient:
while task_list:
task_l
On 6/19/2011 9:24 AM, Steven D'Aprano wrote:
No. Each cell in a Lisp-style linked list has exactly two elements, and
in Python are usually implemented as nested tuples:
(head, tail) # Annoyingly, this is also known as (car, cdr).
where head is the data value and tail is either another Lisp-st
On Mon, Jun 20, 2011 at 1:39 AM, Laurent Claessens wrote:
> My problem is that when FileToCopyTask raises an error, the program does not
> stop.
> In fact when the error is Disk Full, I want to stop the whole program
> because I know that the next task will fail too.
If you're starting a thread f
On 6/19/2011 11:13 AM, Chris Angelico wrote:
On Mon, Jun 20, 2011 at 12:32 AM, TheSaint wrote:
Hello
Trying to pop some key from a dict while is iterating over it will cause an
exception.
How I can remove items when the search result is true.
Example:
while len(dict):
for key in dict.keys
I read the library documentation. I think that if I get a trick to kill
a thread, then I'm done.
Is there a way ?
Laurent
Le 19/06/2011 17:39, Laurent Claessens a écrit :
Le 19/06/2011 17:19, Chris Angelico a écrit :
On Mon, Jun 20, 2011 at 12:42 AM, Laurent Claessens
wrote:
Hello
In article ,
Chris Angelico wrote:
> On Mon, Jun 20, 2011 at 12:32 AM, TheSaint wrote:
> > Hello
> >
> > Trying to pop some key from a dict while is iterating over it will cause an
> > exception.
> > How I can remove items when the search result is true.
> >
> > Example:
> >
> > while len(dict)
In article <4dfe10d1$0$28053$426a3...@news.free.fr>,
candide wrote:
> OK, thanks for your explanation, it was just stringisation !
>
>
> I erroneously focused on
>
> +x+
>
> as a kind of placeholder unknown to me, instead of left and right
> concatenations ;)
>
> It would be more readable
Le 19/06/2011 17:19, Chris Angelico a écrit :
On Mon, Jun 20, 2011 at 12:42 AM, Laurent Claessens wrote:
Hello
I've a list of tasks to perform. Each of them is a threading.Thread.
Basically I have :
while task_list :
task = task_list[0]
task.run()
task_list.remove(task)
Hi Mark,
> The version info comes from the DLL - I wonder if the DLL being found is
> somehow old?
>
> Make sure:
>
> >>> import sys
> >>> win32api.GetModuleFileName(sys.dllhandle)
>
> Is the DLL you expect.
After uninstalling and reinstalling for the current user only (vs. all
users), Python no
On Mon, Jun 20, 2011 at 12:42 AM, Laurent Claessens wrote:
> Hello
>
>
> I've a list of tasks to perform. Each of them is a threading.Thread.
> Basically I have :
>
> while task_list :
> task = task_list[0]
> task.run()
> task_list.remove(task)
I'm not understanding what you're doing with
On Mon, Jun 20, 2011 at 12:32 AM, TheSaint wrote:
> Hello
>
> Trying to pop some key from a dict while is iterating over it will cause an
> exception.
> How I can remove items when the search result is true.
>
> Example:
>
> while len(dict):
> for key in dict.keys():
> if dict[key] is not m
OK, thanks for your explanation, it was just stringisation !
I erroneously focused on
+x+
as a kind of placeholder unknown to me, instead of left and right
concatenations ;)
It would be more readable for me if it were edited
>>> print '"' + x + '"' # better spacing
"foo"
>>>
or with stri
Ethan Furman wrote:
IANAL (I am not a Lisper), but shouldn't that be 'return L[1:]' ?
Ah, thanks all for the clarification.
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
Hello
I've a list of tasks to perform. Each of them is a threading.Thread.
Basically I have :
while task_list :
task = task_list[0]
task.run()
task_list.remove(task)
Now I want, in some circumstance to raise errors that make the loop stop.
In order IOError to make stop the loop
foobar gmail.com> writes:
>
> I've run across a memory leak in a long running process which I can't
> determine if its my issue or if its the logger.
>
BTW did you also ask this question on Stack Overflow? I've answered there, too.
http://stackoverflow.com/questions/6388514/
Regards,
Vinay
zainul franciscus wrote:
> we are looking for
> some ideas for good functionality for the application. T
I was looking for a file cataloger. this program may go into same category
as far as handling file names ad file system's structures.
It also manage to store unused files into zipped archives
Hello
Trying to pop some key from a dict while is iterating over it will cause an
exception.
How I can remove items when the search result is true.
Example:
while len(dict):
for key in dict.keys():
if dict[key] is not my_result:
dict.pop(key)
else:
condition_to_brea
SherjilOzair wrote:
> There are basically two ways to go about this.
[...]
> What has the community to say about this ? What is the best (fastest)
> way to insert sorted in a list ?
a third way maybe using a SkipList instead of a list
on http://infohost.nmt.edu/tcc/help/lang/python/examples/py
foobar gmail.com> writes:
> I've run across a memory leak in a long running process which I can't
> determine if its my issue or if its the logger.
As Chris Torek said, it's not a good idea to create a logger for each thread. A
logger name represents a place in your application; typically, a mod
Ethan Furman writes:
>> def car(L):
>> return L[0]
>> def cdr(L):
>> return L[1]
>
> IANAL (I am not a Lisper), but shouldn't that be 'return L[1:]' ?
Not for the linked list implementation he presented.
>> def length(L):
>> if not L: return 0
>> return 1 + length(cdr(L))
>
> Ho
On Sun, Jun 19, 2011 at 11:41 PM, candide wrote:
> With Python 2.7 :
>
x="foo"
print '"'+x+'"'
> "foo"
As Laurent posted, it's simply a literal double-quote character,
enclosed in single quotes. But for making a quoted string, this isn't
reliable (what if there's a double quote in
On Sun, Jun 19, 2011 at 2:41 PM, candide wrote:
> With Python 2.7 :
>
x="foo"
print '"'+x+'"'
> "foo"
> What is this curious syntax on line 2 ? Where is it documented ?
Just to make it clear to you what is happening -
>>> x = "foo"
>>> print ' " ' + x + ' " '
" foo "
>>>
Anyway, it'
Le 19/06/2011 15:41, candide a écrit :
With Python 2.7 :
>>> x="foo"
>>> print '"'+x+'"'
"foo"
>>>
What is this curious syntax on line 2 ? Where is it documented ?
When you want to have an explicit double quote " in a string, you put in
between single quote '.
(and vice versa)
So
With Python 2.7 :
>>> x="foo"
>>> print '"'+x+'"'
"foo"
>>>
What is this curious syntax on line 2 ? Where is it documented ?
--
http://mail.python.org/mailman/listinfo/python-list
On Sun, 19 Jun 2011 15:56:27 +0300, Ethan Furman wrote:
Lie Ryan wrote:
def length(L):
if not L: return 0
return 1 + length(cdr(L))
How is this different from regular ol' 'len' ?
It's better, because len() can't overflow the stack. ;)
--
http://mail.python.org/mailman/listinfo/py
On Sun, 19 Jun 2011 05:56:27 -0700, Ethan Furman wrote:
> Lie Ryan wrote:
>> On 06/18/11 00:45, Franck Ditter wrote:
>>> Hi, I'm just wondering about the complexity of some Python operations
>>> to mimic Lisp car and cdr in Python...
>>>
>>> def length(L) :
>>> if not L : return 0
>>> return 1
On Sun, Jun 19, 2011 at 10:56 PM, Ethan Furman wrote:
> Lie Ryan wrote:
>> def cdr(L):
>> return L[1]
>
> IANAL (I am not a Lisper), but shouldn't that be 'return L[1:]' ?
In LISP, a list is a series of two-item units (conses).
>> L = (a, (b, (c, (d, None
This represents the LISP equival
On Fri, 17 Jun 2011 20:53:39 +0300, gervaz wrote:
I decided to implement this solution:
class HeadRequest(urllib.request.Request):
def get_method(self):
return "HEAD"
Now I download the url using:
r = HeadRequest(url, None, self.headers)
c = urllib.request.urlopen(r)
but I don't
Lie Ryan wrote:
On 06/18/11 00:45, Franck Ditter wrote:
Hi, I'm just wondering about the complexity of some Python operations
to mimic Lisp car and cdr in Python...
def length(L) :
if not L : return 0
return 1 + length(L[1:])
Should I think of the slice L[1:] as (cdr L) ? I mean, is the s
Steven D'Aprano writes:
>> Supply the client with tamper-proof hardware containing a private key.
>
> Is that resistant to man-in-the-middle attacks by somebody with a packet
> sniffer watching the traffic between the device and the website?
Sure, why not? As long as the crypto is done properly
On Sun, 19 Jun 2011 05:47:30 +0100, Nobody wrote:
> On Sat, 18 Jun 2011 04:34:55 -0700, mzagu...@gmail.com wrote:
>
>> I am wondering what your strategies are for ensuring that data
>> transmitted to a website via a python program is indeed from that
>> program, and not from someone submitting PO
Just wanted to thank you guys for taking the time to respond. Looks like my
'limited resources' aren't so limited after all!
Cheers,
Anthony
--
http://mail.python.org/mailman/listinfo/python-list
Cathy James, 19.06.2011 01:21:
def fileProcess(filename):
"""Call the program with an argument,
it should treat the argument as a filename,
splitting it up into words, and computes the length of each word.
print a table showing the word count for each of the word lengths
that
Chris Rebert writes:
> Also, in the future, avoid replying to the mailinglist digest, or at
> the very least please trim off the irrelevant quoted posts in your
> reply.
Right. It will help communication greatly if you reply inline with
specific quoted material (what Wikipedia calls “interleaved
58 matches
Mail list logo