On 03/16/2015 02:29 PM, Rajbir Singh wrote:
i need to know how i can set current working dir in an executing phython
using os module
os.chdir() will change the current directory, but it changes it for the
whole program (all threads), and the change lasts till the program
terminates.
Very of
Rajbir Singh writes:
> i need to know how i can set current working dir in an executing
> phython using os module
Why must it be using the ‘os’ module? It's generally a bad idea to
assume you need a specific module to provide the solution; better to
describe what you need to do, and not assume w
On 16 March 2015 at 18:29, Rajbir Singh wrote:
>
> i need to know how i can set current working dir in an executing phython
> using os module
If you explain why you want to do that then it may be that there is a
better way to achieve what you want. It's usually not necessary to
change the current
On 16/03/15 18:29, Rajbir Singh wrote:
i need to know how i can set current working dir in an executing phython
using os module
try
os.chdir('/some/path/here')
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo
i need to know how i can set current working dir in an executing phython
using os module
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
On 21/05/14 13:39, Shweta Kaushik wrote:
Hi All,
I am new to python. Please help me.
I have to create one function which can set values sent by user from a list of
values.
For eg:
I have a list having values between 1 to 100.
List = ['1', '2', ... '100']
I have to write a function to set valu
Shweta Kaushik Wrote in message:
> Hi All,
>
> I am new to python. Please help me.
> I have to create one function which can set values sent by user from a list
> of values.
>
> For eg:
> I have a list having values between 1 to 100.
> List = ['1', '2', ... '100']
>
> I have to write a functi
> take value 15 from list
Hint: use square brackets to choose a particular item from a list.
test = ['first', 'second', 'third']
test[0] would refer to 'first' for example.
Alan
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscri
Hi All,
I am new to python. Please help me.
I have to create one function which can set values sent by user from a list of
values.
For eg:
I have a list having values between 1 to 100.
List = ['1', '2', ... '100']
I have to write a function to set values from the list based on user input.
If u
On 12/18/2013 09:45 PM, Alan Gauld wrote:
On 18/12/13 17:45, Mark Lawrence wrote:
Can I be so bold as to ask how discussing metaclasses and __setattr__ on
a tutor mailing list is going to help the newbie who's having problems
with their "hello world" program?
It won't, but the tutor list is a
On Wed, Dec 18, 2013 at 6:16 AM, spir wrote:
> On 12/18/2013 12:07 PM, eryksun wrote:
>>
>> You need __setattr__ from the metaclass:
>>
>> >>> class C: pass
>> ...
>> >>> type(C).__setattr__(C, "baz", "BAZ")
>> >>> C.baz
>> 'BAZ'
>
> Oh, that makes sense: so, __setattr__ o
On Wed, Dec 18, 2013 at 05:45:02PM +, Mark Lawrence wrote:
> Can I be so bold as to ask how discussing metaclasses and __setattr__ on
> a tutor mailing list is going to help the newbie who's having problems
> with their "hello world" program?
It's not just newbies who need tutoring. Sometim
On 18/12/13 17:45, Mark Lawrence wrote:
Can I be so bold as to ask how discussing metaclasses and __setattr__ on
a tutor mailing list is going to help the newbie who's having problems
with their "hello world" program?
It won't, but the tutor list is also for experienced programmers new
to Pyth
On 18/12/2013 11:16, spir wrote:
On 12/18/2013 12:07 PM, eryksun wrote:
On Wed, Dec 18, 2013 at 5:40 AM, spir wrote:
C.__setattr__(C, "baz", "BAZ")
which fails, for any reason, with
TypeError: can't apply this __setattr__ to type object
You need __setattr__ from the metaclass:
On 12/18/2013 11:51 AM, eryksun wrote:
On Tue, Dec 17, 2013 at 10:52 AM, spir wrote:
is it at all possible to set new vars (or any symbol) into an existing scope
(typically locals())?
scope[name] = value
raises by me an error like:
TypeError: 'mappingproxy' object does not support it
On 12/18/2013 12:07 PM, eryksun wrote:
On Wed, Dec 18, 2013 at 5:40 AM, spir wrote:
C.__setattr__(C, "baz", "BAZ")
which fails, for any reason, with
TypeError: can't apply this __setattr__ to type object
You need __setattr__ from the metaclass:
>>> class C: pass
...
On Wed, Dec 18, 2013 at 5:40 AM, spir wrote:
> C.__setattr__(C, "baz", "BAZ")
> which fails, for any reason, with
> TypeError: can't apply this __setattr__ to type object
You need __setattr__ from the metaclass:
>>> class C: pass
...
>>> type(C).__setattr__(C, "baz", "BAZ")
On Tue, Dec 17, 2013 at 10:52 AM, spir wrote:
> is it at all possible to set new vars (or any symbol) into an existing scope
> (typically locals())?
>
> scope[name] = value
> raises by me an error like:
> TypeError: 'mappingproxy' object does not support item assignment
>
> I guess 'mappin
On 12/18/2013 10:02 AM, Peter Otten wrote:
spir wrote:
[...]
Like Steven I have no idea how you produced the mappingproxy. Are you trying
to use a class as a namespace (in Python 3.3)?
class A: pass
...
A.__dict__["foo"] = "bar"
Traceback (most recent call last):
File "", line 1, in
Type
spir wrote:
> Hello,
>
> is it at all possible to set new vars (or any symbol) into an existing
> scope (typically locals())?
locals() normally contains a copy of the current namespace as a dict.
Setting items is possible but only alters the dict and has no effect on the
original namespace:
>
On Tue, Dec 17, 2013 at 04:52:25PM +0100, spir wrote:
> Hello,
>
> is it at all possible to set new vars (or any symbol) into an existing
> scope (typically locals())?
In general, no. The only time that writing to locals() is guaranteed to
work is when you are in the top-level scope and locals
Hello,
is it at all possible to set new vars (or any symbol) into an existing scope
(typically locals())?
scope[name] = value
raises by me an error like:
TypeError: 'mappingproxy' object does not support item assignment
I guess 'mappingproxy' is the implementation name of a scope (her
FWIW, I'd like to reverse my answer, and now I agree with Oscar's 29 Jan
suggestion to make "Reply-to-tutor-list" the default.
Lately, several times a tutor had to forward to the list an email meant for
the list but sent to him only, by mistake. On the other hand, the
wrote-to-1-person-but-mistake
My personal opinion (with whatever limited weight that has on this list
since I've only answered a few questions - and probably half of them I've
accidentally only sent to the op)/how I read it is that RFC 2822 actually
allows lists to set reply-to header; by my view the list software is
forwarding
>
> To summarize existing opinions on this matter:
>
> http://marc.merlins.org/netrants/listreplyto.html
>
> You might want to familiarize yourself with existing literature on the
> matter before starting a new flame war.
Hmmm... False alarm?
Page blocked
The page you've been trying to a
Oscar Benjamin writes:
> I have both sent and received messages on this list that went off-list
> by mistake. It's an easy mistake to make that you use reply instead of
> reply-all and then the message goes just to one person instead of the
> whole list.
>
> This problem is not unique to the pyth
El 29/01/2013, a las 04:14 a.m., Oscar Benjamin
escribió:
> I see the mailing list as being fundamentally a public message forum
> and only very occasionally send an off-list message.
> Often this means that the archives are incomplete, so that there is a
> thread but the part of the thread wher
On Tue, Jan 29, 2013 at 9:12 PM, Oscar Benjamin
wrote:
> If you don't mind my asking, do you send many off-list messages as
> replies to on-list ones?
> Oscar
>
For this list, I have sent 1 public reply and 2 private replies (to thank
individual tutors). Both numbers are too small to have any sig
On 29 January 2013 03:35, DoanVietTrungAtGmail wrote:
> As a student user of this list, I prefer leaving the Reply-To field
> unchanged. I like the fact that this means a deliberate decision is
> required to send public emails.
If you don't mind my asking, do you send many off-list messages as
r
As a student user of this list, I prefer leaving the Reply-To field
unchanged. I like the fact that this means a deliberate decision is
required to send public emails.
Trung
On Tue, Jan 29, 2013 at 12:17 PM, Steven D'Aprano wrote:
> On 29/01/13 09:04, Oscar Benjamin wrote:
>
> One particular l
On 29/01/13 09:04, Oscar Benjamin wrote:
One particular list that I receive has recently made an administrative
change so that, from now on, all emails have the "Reply-To" header set
to the list address. This means that the default behaviour when
replying to a message is that the reply goes to t
On Sat, Jan 19, 2013 at 7:24 AM, Albert-Jan Roskam wrote:
>
> But is Windows the only exception in the way that libraries are dealt with?
> Or do DLLs also have a dynamic area?
DLLs can have an embedded manifest. To solve the DLL Hell problem,
Windows introduced side-by-side assemblies (WinSxS):
On Fri, Jan 18, 2013 at 4:07 PM, Albert-Jan Roskam wrote:
>
> Alan said:
>> Support for changing environment variables on the fly is iffy in most
>> languages and is not something I'd ever do lightly.
>
> If you put it that way... yes, I now realize that it could be (and in fact
> is) really annoy
On 19/01/13 12:24, Albert-Jan Roskam wrote:
Thank you! I am getting a whole lot wiser wrt Linux. I checked 'man ld' and
'man ldconfig'.
Especially the ld command is pretty extensive. The Rpath/Runpath solution seems
nice in that
no wrapper is needed (contrary to when one uses LD_LIBRARY_PATH).
> On Thu, Jan 17, 2013 at 10:33 AM, Albert-Jan Roskam
> wrote:
>>
>> The goal is to load the C libraries (dll, so, dylib, etc) that my program
>> needs.
>>
>> Anyway, I looked up your two suggestions about library_dirs and
>> runtime_library_dirs. What is meant by "at link time"?
>
> lib
>> Thanks for your replies. os.putenv() may be easier than os.environ because,
>> hopefully, it takes care of the OS-specific separators of the values
>> (";" for Windows, ":" for Linux, others I don't
> know
>
> I wouldn't count on it. Support for changing environment variables on the
> fl
On Thu, Jan 17, 2013 at 10:33 AM, Albert-Jan Roskam wrote:
>
> The goal is to load the C libraries (dll, so, dylib, etc) that my program
> needs.
>
> Anyway, I looked up your two suggestions about library_dirs and
> runtime_library_dirs. What is meant by "at link time"?
library_dirs adds search p
On 17/01/13 12:14, Albert-Jan Roskam wrote:
Thanks for your replies. os.putenv() may be easier than os.environ because,
> hopefully, it takes care of the OS-specific separators of the values
> (";" for Windows, ":" for Linux, others I don't know
I wouldn't count on it. Support for changing env
Original Message -
> From: eryksun
> To: Albert-Jan Roskam
> Cc: Python Mailing List
> Sent: Thursday, January 17, 2013 3:21 PM
> Subject: Re: [Tutor] Set LD_LIBRARY_PATH and equivalents
> platform-independently
>
> On Wed, Jan 16, 2013 at 4:06 PM, Alb
On Thu, Jan 17, 2013 at 7:14 AM, Albert-Jan Roskam wrote:
>
> Thanks for your replies. os.putenv() may be easier than os.environ because,
> hopefully, it takes care of the OS-specific separators of the values (";"
> for Windows, ":" for Linux, others I don't know but I'd guess they're all
> ":").
On Wed, Jan 16, 2013 at 4:06 PM, Albert-Jan Roskam wrote:
>
> Is there a builtin function that can set LD_LIBRARY_PATH or equivalents
> platform-independently? It would be nice use such a function in a setup
> script.
Modifying LD_LIBRARY_PATH only affects child processes (ld.so caches
the search
> Subject: Re: [Tutor] Set LD_LIBRARY_PATH and equivalents
> platform-independently
>
> On 01/16/2013 07:05 PM, Alan Gauld wrote:
>> On 16/01/13 21:06, Albert-Jan Roskam wrote:
>>
>>> Is there a builtin function that can set LD_LIBRARY_PATH or equiva
On 17/01/13 02:10, Dave Angel wrote:
I don't recall enough about Windows to be sure whether putenv would
work, but the environment variable Windows uses to search for DLL's is
certainly not LD_LIBRARY_PATH
If you check the code Albert is actually using different variables per
platform. For Wi
On 01/16/2013 07:05 PM, Alan Gauld wrote:
On 16/01/13 21:06, Albert-Jan Roskam wrote:
Is there a builtin function that can set LD_LIBRARY_PATH or equivalents
platform-independently?
No.
But there is putenv() in the os module.
But how well it works across OS I'm not sure.
I don't recall eno
On 16/01/13 21:06, Albert-Jan Roskam wrote:
Is there a builtin function that can set LD_LIBRARY_PATH or equivalents
platform-independently?
No.
But there is putenv() in the os module.
But how well it works across OS I'm not sure.
HTH
--
Alan G
Author of the Learn to Program web site
http://ww
Hello,
Is there a builtin function that can set LD_LIBRARY_PATH or equivalents
platform-independently? It would be nice use such a function in a setup script.
The code below illustrates what I mean, although it's entirely untested.
import sys
import os
def setPath(loc):
"""Set LD_LIBRARY_PA
On Fri, Jun 24, 2011 at 1:31 PM, Christian Witts wrote:
> On 2011/06/24 01:19 PM, Norman Khine wrote:
>
> thank you, it was simpler than what i was trying to do, here is the
> revised version:
>
> http://pastie.org/2115586
>
> one thing i am getting an error is on like 103, in that if, i change
>
On 2011/06/24 01:19 PM, Norman Khine wrote:
thank you, it was simpler than what i was trying to do, here is the
revised version:
http://pastie.org/2115586
one thing i am getting an error is on like 103, in that if, i change
(http://pastie.org/2115615):
-plt.legend(('Income - GBP', 'Discounts',
Norman Khine wrote:
> thank you, it was simpler than what i was trying to do, here is the
> revised version:
>
> http://pastie.org/2115586
>
> one thing i am getting an error is on like 103, in that if, i change
> (http://pastie.org/2115615):
>
> -plt.legend(('Income - GBP', 'Discounts', 'Googl
thank you, it was simpler than what i was trying to do, here is the
revised version:
http://pastie.org/2115586
one thing i am getting an error is on like 103, in that if, i change
(http://pastie.org/2115615):
-plt.legend(('Income - GBP', 'Discounts', 'Google AdWords - GBP',
'Commission - %s GBP'
Norman Khine wrote:
> hello, i have this code http://pastie.org/2112997
>
> but i am not sure how to make the date range so that i get a list
> based on the daily totals not the results i am now getting:
>
> (2L, Decimal('173.958344'), Decimal('159.966349')) 2011-06-23 00:00:00
> 2011-06-23 23:5
hello, i have this code http://pastie.org/2112997
but i am not sure how to make the date range so that i get a list
based on the daily totals not the results i am now getting:
(2L, Decimal('173.958344'), Decimal('159.966349')) 2011-06-23 00:00:00
2011-06-23 23:59:59
(2L, Decimal('173.958344'), De
On Thu, 22 Apr 2010 02:28:03 am Bala subramanian wrote:
> Friends,
> Someone please write me the difference between creating set with
> set() and a sets.Set().
The sets module, including sets.Set(), were first introduced in Python
2.3 and is written in Python.
The built-in set object was introdu
> When sets were introduced to Python in version 2.3. they came as a separate
> "sets" module.
>
> In version 2.6 built-in set/frozenset types replaced this module.
2.4
> So either way is OK for now, but the sets module might go away in a newer
> version.
agreed
cheers,
-- wesley
- - - - - -
On 4/21/2010 12:28 PM, Bala subramanian wrote:
Friends,
Someone please write me the difference between creating set with set()
and a sets.Set().
When sets were introduced to Python in version 2.3. they came as a
separate "sets" module.
In version 2.6 built-in set/frozenset types replaced th
Friends,
Someone please write me the difference between creating set with set() and a
sets.Set().
>>> a=set([1,2,3])
>>> b=sets.Set([1,2,3])
>>> print a
set([1, 2, 3])
>>> print b
Set([1, 2, 3])
Thanks,
Bala
___
Tutor maillist - Tutor@python.org
To un
On Sat, Jan 31, 2009 at 4:51 AM, prasad rao wrote:
> hell
> I got a problem sorting a list of lists.
> ml=
> [[112, 'p'], [114, 'r'], [97, 'a'], [115, 's'], [97, 'a'], [100, 'd'], [97,
> 'a'], [114, 'r'], [97, 'a'], [111, 'o']]
> sorted(ml,key=?)
> How can I formulate a key to sort based on the fi
On Sat, Jan 31, 2009 at 10:51, prasad rao wrote:
> I got a problem sorting a list of lists.
> ml=
> [[112, 'p'], [114, 'r'], [97, 'a'], [115, 's'], [97, 'a'], [100, 'd'], [97,
> 'a'], [114, 'r'], [97, 'a'], [111, 'o']]
> sorted(ml,key=?)
> How can I formulate a key to sort based on the first eleme
hellI got a problem sorting a list of lists.
ml=
[[112, 'p'], [114, 'r'], [97, 'a'], [115, 's'], [97, 'a'], [100, 'd'], [97,
'a'], [114, 'r'], [97, 'a'], [111, 'o']]
sorted(ml,key=?)
How can I formulate a key to sort based on the first element of each list.
sorting list of lists might have been d
On 1/20/07, Kent Johnson <[EMAIL PROTECTED]> wrote:
> Adam Cripps wrote:
> > Many thanks all - I've got there in the end, using a tuple inside a
> > set, ditching the question number and then rendering the sum for
> > output in my main gui module.
> >
> > However, this does raise another issue now
Adam Cripps wrote:
> Many thanks all - I've got there in the end, using a tuple inside a
> set, ditching the question number and then rendering the sum for
> output in my main gui module.
>
> However, this does raise another issue now (which I had thought would
> happen, but was putting it off unt
On 1/20/07, Kent Johnson <[EMAIL PROTECTED]> wrote:
> Adam Cripps wrote:
> > On 1/19/07, Simon Brunning <[EMAIL PROTECTED]> wrote:
> >> On 1/19/07, Adam Cripps <[EMAIL PROTECTED]> wrote:
> >>> I'm adding strings to a Set to prevent duplicates. However, the
> >>> strings are meant to be in the corre
Adam Cripps wrote:
> On 1/19/07, Simon Brunning <[EMAIL PROTECTED]> wrote:
>> On 1/19/07, Adam Cripps <[EMAIL PROTECTED]> wrote:
>>> I'm adding strings to a Set to prevent duplicates. However, the
>>> strings are meant to be in the correct order. When I add the string to
>>> the Set, the order seem
On Fri, 2007-01-19 at 20:05 +, Adam Cripps wrote:
> On 1/19/07, Simon Brunning <[EMAIL PROTECTED]> wrote:
> > On 1/19/07, Adam Cripps <[EMAIL PROTECTED]> wrote:
> > > I'm adding strings to a Set to prevent duplicates. However, the
> > > strings are meant to be in the correct order. When I add t
On Fri, 19 Jan 2007, Adam Cripps wrote:
> I'm adding strings to a Set to prevent duplicates. However, the strings
> are meant to be in the correct order. When I add the string to the Set,
> the order seems to change (and I don't seem to be able to predict what
> order they are in).
Hi Adam,
On 1/19/07, Simon Brunning <[EMAIL PROTECTED]> wrote:
> On 1/19/07, Adam Cripps <[EMAIL PROTECTED]> wrote:
> > I'm adding strings to a Set to prevent duplicates. However, the
> > strings are meant to be in the correct order. When I add the string to
> > the Set, the order seems to change (and I don
On 1/19/07, Adam Cripps <[EMAIL PROTECTED]> wrote:
> I'm adding strings to a Set to prevent duplicates. However, the
> strings are meant to be in the correct order. When I add the string to
> the Set, the order seems to change (and I don't seem to be able to
> predict what order they are in).
Sets
I'm adding strings to a Set to prevent duplicates. However, the
strings are meant to be in the correct order. When I add the string to
the Set, the order seems to change (and I don't seem to be able to
predict what order they are in).
The string is a simple addition question which should look like
> I use:
>
> Python 2.3.4 (#2, Aug 19 2004, 15:49:40) [GCC 3.4.1 (Mandrakelinux (Alpha
> 3.4.1-3mdk)] on linux2 ... IDLE 1.0.3
>
> I wa
I use:
Python 2.3.4 (#2, Aug 19 2004, 15:49:40) [GCC 3.4.1 (Mandrakelinux (Alpha
3.4.1-3mdk)] on linux2 ... IDLE 1.0.3
I was trying to wr
70 matches
Mail list logo