Accidentally hit post by mistake before msg completed.
Any comments appreciated. It's a very simple scenario, but not sure what
the mistake is.
Thanks
Jason
On Tue, Feb 28, 2012 at 6:55 PM, Jason Veldicott
wrote:
> Hi,
>
> I have a simple configuration of modules as beneath, but an import er
Jason Veldicott wrote:
> Hi,
>
> I have a simple configuration of modules as beneath, but an import error
> is reported:
>
> /engine
>(__init__ is empty here)
>engine.py
> /sim
>__init__.py
>
>
> The module engine.py imports a variable instantiated in sim.__init__ as
> follows:
>
How should I check if I can create files in a directory?
I tried to simply check if the directory is writeable with this function:
def is_writable(name):
"""Return true if the file is writable from the current user
"""
return os.access(name, os.W_OK)
but that doesn't work at all on
On Feb 28, 1:36 am, Steven D'Aprano wrote:
> On Mon, 27 Feb 2012 12:48:27 -0800, Alex Borghgraef wrote:
> > Hi all,
>
> > Some time ago I've written some python code to read video data off an IP
> > camera connected via a router to a laptop. Now I try to run this code on
> > a different laptop and
On Feb 28, 10:50 am, Alex Borghgraef
wrote:
> I'll still have to find out a way to get this thing working with proxy
> enabled if I ever want to connect it to our overall network.
Ok, doing os.environ['http_proxy']='' before importing urllib2 seems
to do the trick for that.
--
Alex
--
http:/
On 28/02/2012 10:07, Andrea Crotti wrote:
How should I check if I can create files in a directory?
I tried to simply check if the directory is writeable with this function:
def is_writable(name):
"""Return true if the file is writable from the current user
"""
return os.access(name, os.W_OK)
b
Steven D'Aprano writes:
> On Sun, 26 Feb 2012 19:47:49 +1100, Ben Finney wrote:
>
> >> An integer variable is a variable holding an integer. A string variable
> >> is a variable holding a string. A list variable is a variable holding a
> >> list.
> >
> > And Python has none of those. Its referen
On 02/28/2012 11:34 AM, Tim Chase wrote:
On 02/28/12 04:07, Andrea Crotti wrote:
How should I check if I can create files in a directory?
So maybe the only solution that works is something like
try:
open(path.join('temp', 'w'))
except OsError:
return False
else:
os.remove(path
On 02/28/12 04:07, Andrea Crotti wrote:
How should I check if I can create files in a directory?
So maybe the only solution that works is something like
try:
open(path.join('temp', 'w'))
except OsError:
return False
else:
os.remove(path.join('temp'))
return True
It depe
On 02/28/12 06:01, Andrea Crotti wrote:
How should I check if I can create files in a directory?
But isn't there (or should there be) a windows-related library that
abstracts this horrible things?
Yes, there should be. There isn't as far as I know (though that
doesn't mean much given my limi
I have created a bytestream (readfile.pkl) from pickle.dump() already in
different folder (say /tmp) succesfully. Now I wish to open the file, read
it and finally write the output to a file to "output.txt".
To read the file bytestream file (readfile.pkl) I did perform as --
---
import pickle
def
"Frank Millman" wrote in message
news:jii0vo$36t$1...@dough.gmane.org...
> Hi all
>
> This is a follow-up to my recent question about circular imports, but on a
> different subject, hence the new thread.
>
[...]
>
> If this makes sense, my next thought was, where is the best place to put
> thi
On 28/02/2012 12:01, Andrea Crotti wrote:
On 02/28/2012 11:34 AM, Tim Chase wrote:
On 02/28/12 04:07, Andrea Crotti wrote:
How should I check if I can create files in a directory?
So maybe the only solution that works is something like
try:
open(path.join('temp', 'w'))
except OsError:
return F
On Tue, 28 Feb 2012 22:36:56 +1100, Ben Finney wrote:
> Steven D'Aprano writes:
>
>> On Sun, 26 Feb 2012 19:47:49 +1100, Ben Finney wrote:
>>
>> >> An integer variable is a variable holding an integer. A string
>> >> variable is a variable holding a string. A list variable is a
>> >> variable ho
Hi All,
I'm pleased to announce the release of xlrd 0.7.3.
This release just brings in some documentation updates that were missed
for 0.7.2.
cheers,
Chris
--
Simplistix - Content Management, Batch Processing & Python Consulting
- http://www.simplistix.co.uk
--
http://mail.pytho
I have a script that might be used interactively but also has some
arguments that
should not be used by "normal" users.
So I just want to suppress them from the help.
I've read somewhere that the help=SUPPRESS should do what I want:
parser.add_argument('-n', '--test_only',
I am looking for pickle performing class instantiation, something as
prototype like -
- Have a class
- Instantiate the class with 3 parameters
- pickle the class instance
- generate a bytestream (.pkl) using pickle.dump
--
http://mail.python.org/mailman/listinfo/python-list
Am I doing the right thing for -
- Have a class
- Instantiate the class with 3 parameters
- pickle the class instance
- generate a bytestream (.pkl) using pickle.dump, simply guessing -
as -
---
#!/usr/bin/python
import pickle
class Pickle:
def __init__(self, Parameter1, Parameter2, Parame
Andrea Crotti wrote:
> I have a script that might be used interactively but also has some
> arguments that
> should not be used by "normal" users.
> So I just want to suppress them from the help.
> I've read somewhere that the help=SUPPRESS should do what I want:
>
> parser.add_argument('-n'
>class Pickle:
> def __init__(self, Parameter1, Parameter2, Parameter3):
> self.PM1 = Parameter1
> self.PM2 = Parameter2
> self.PM3 = Parameter3
>with open('/tmp/readfile.pkl', 'wb') as f:
> pickle.dump((self.PM1, self.PM2, self.PM3), f)
>with open('/tmp/readfile.pk
Smiley 4321 wrote:
> Am I doing the right thing for -
>
> - Have a class
> - Instantiate the class with 3 parameters
> - pickle the class instance
> - generate a bytestream (.pkl) using pickle.dump, simply guessing -
>
> as -
>
> ---
> #!/usr/bin/python
>
> import pickle
>
> class Pickle:
>
On 2/28/2012 9:54 AM, Smiley 4321 wrote:
> NameError: name 'self' is not defined
self is meaningless outside a class definition. You should refactor your
dump, load and print code as methods inside the class definition, create
an instance and call the methods on that instance.
--
CPython 3.2.2 |
On 02/28/2012 04:02 PM, Peter Otten wrote:
Andrea Crotti wrote:
I have a script that might be used interactively but also has some
arguments that
should not be used by "normal" users.
So I just want to suppress them from the help.
I've read somewhere that the help=SUPPRESS should do what I want
If I do a time.sleep(0.001) right at the beginning of the run() method,
then it completes fine.
I was able to run it through a couple hundred times without problem.
If I sleep for less time than that or not at all, it may or may not
complete.
On Mon, Feb 27, 2012 at 9:38 PM, MRAB wrote:
> On 27/
Hi All,
I'm new to Python but have experience with a few other programming
languages(Java, Perl, JavaScript).
I'm using Python 2.7.2 and I'm trying to create and write to a file (.py) a
python class and functions from python. I will also need to later read and edit
the file. I realize I could
Can I have some thoughts about - building a GUI to display the results of
the pickle read?
A prototype code should be fine on Linux.
~ BR
--
http://mail.python.org/mailman/listinfo/python-list
crs...@gmail.com wrote:
> I'm new to Python but have experience with a few other programming
> languages(Java, Perl, JavaScript).
>
> I'm using Python 2.7.2 and I'm trying to create and write to a file (.py)
> a python class and functions from python. I will also need to later read
> and edit the
在 2012年2月29日星期三UTC+8上午1时56分43秒,Peter Otten写道:
> crs...@gmail.com wrote:
>
> > I'm new to Python but have experience with a few other programming
> > languages(Java, Perl, JavaScript).
> >
> > I'm using Python 2.7.2 and I'm trying to create and write to a file (.py)
> > a python class and function
On 28/02/2012 17:16, Eric Frederich wrote:
If I do a time.sleep(0.001) right at the beginning of the run() method,
then it completes fine.
I was able to run it through a couple hundred times without problem.
If I sleep for less time than that or not at all, it may or may not
complete.
[snip]
T
Andrea Crotti wrote:
> On 02/28/2012 04:02 PM, Peter Otten wrote:
>> Andrea Crotti wrote:
>>
>>> I have a script that might be used interactively but also has some
>>> arguments that
>>> should not be used by "normal" users.
>>> So I just want to suppress them from the help.
>>> I've read somewher
On Tue, Feb 28, 2012 at 12:51 PM, Smiley 4321 wrote:
> Can I have some thoughts about - building a GUI to display the results of
> the pickle read?
>
> A prototype code should be fine on Linux.
It doesn't seem like it would be all that useful, though I may just be
lacking in imagination. What wo
On Tuesday, February 28, 2012 9:56:43 AM UTC-8, Peter Otten wrote:
> crs...@gmail.com wrote:
>
> > I'm new to Python but have experience with a few other programming
> > languages(Java, Perl, JavaScript).
> >
> > I'm using Python 2.7.2 and I'm trying to create and write to a file (.py)
> > a pyth
I'm trying to compute the total CPU load of an external process and it's
children. (so I cannot use resource.getrusage) For the load of the
process I can just grab it from /proc/X/stat. How do I get the CPU load of
the children processes? Is there an easy way to get a list of the children
proce
On Tue, Feb 28, 2012 at 12:51 PM, Smiley 4321 wrote:
Can I have some thoughts about - building a GUI to display the results of
the pickle read?
A prototype code should be fine on Linux.
What on earth is this post asking?
Do you want code? Opinions?
--
http://mail.python.org/mailman/listinfo
OKB (not okblacke) wrote:
Anyway, testing this just reinforced my distaste for circular
imports. Just trying to think about how it ought to work with a
importing c but then c and d importing each other makes my brain hurt.
Refactoring the files so that common code is in a separate librar
Michael Torrie wrote:
He's simply showing you the hex (binary) representation of the
floating-point number's binary representation. As you can clearly see
in the case of 1.1, there is no finite sequence that can store that.
You end up with repeating numbers.
Thanks for the explanation.
Thi
crs...@gmail.com wrote:
> On Tuesday, February 28, 2012 9:56:43 AM UTC-8, Peter Otten wrote:
>> crs...@gmail.com wrote:
>>
>> > I'm new to Python but have experience with a few other programming
>> > languages(Java, Perl, JavaScript).
>> >
>> > I'm using Python 2.7.2 and I'm trying to create and
On 02/27/2012 10:26 PM, Ben Held wrote:
Hello,
After upgrading from Python 2.6 to 3.2 in our application we noticed that after
calling Py_Initialize, our output from std::wcout has extra spaces in it:
wcout<< L"Just a test\n";
now prints out:
J u s t a t e s t
Any clue why?
Ben Held
On Tuesday, February 28, 2012 11:25:33 AM UTC-8, Peter Otten wrote:
> crs...@gmail.com wrote:
>
> > On Tuesday, February 28, 2012 9:56:43 AM UTC-8, Peter Otten wrote:
> >> crs...@gmail.com wrote:
> >>
> >> > I'm new to Python but have experience with a few other programming
> >> > languages(Java,
On Tue, Feb 28, 2012 at 10:33 AM, Mihai Badoiu wrote:
> I'm trying to compute the total CPU load of an external process and it's
> children. (so I cannot use resource.getrusage) For the load of the process
> I can just grab it from /proc/X/stat. How do I get the CPU load of the
> children proce
Looked at that before. psutil doesn't do children.
--mihai
On Tue, Feb 28, 2012 at 4:35 PM, Chris Rebert wrote:
> On Tue, Feb 28, 2012 at 10:33 AM, Mihai Badoiu wrote:
> > I'm trying to compute the total CPU load of an external process and it's
> > children. (so I cannot use resource.getrusa
On 28 February 2012 21:39, Mihai Badoiu wrote:
> On Tue, Feb 28, 2012 at 4:35 PM, Chris Rebert wrote:
>>
>> On Tue, Feb 28, 2012 at 10:33 AM, Mihai Badoiu wrote:
>> > I'm trying to compute the total CPU load of an external process and it's
>> > children. (so I cannot use resource.getrusage) Fo
I see that there was previously a PEP to allow the with statement to skip the
enclosing block... this was shot down, and I'm trying to think of the most
elegant alternative.
The best I've found is to abuse the for notation:
for _ in cachingcontext(x):
# create cached resources here
# return
Craig Yoshioka wrote:
>I see that there was previously a PEP to allow the with statement to skip the
>enclosing block... this was shot down, and I'm trying to think of the most
>elegant alternative. [..]
>I would have really liked:
>with cachingcontext(x):
># create cached resources here
>#
On Tue, Feb 28, 2012 at 1:07 PM, Peter Otten <__pete...@web.de> wrote:
> Andrea Crotti wrote:
>
>> On 02/28/2012 04:02 PM, Peter Otten wrote:
>>> Andrea Crotti wrote:
>>>
I have a script that might be used interactively but also has some
arguments that
should not be used by "normal"
On Tue, Feb 28, 2012 at 1:04 PM, Craig Yoshioka wrote:
>
> I see that there was previously a PEP to allow the with statement to skip the
> enclosing block... this was shot down, and I'm trying to think of the most
> elegant alternative.
> The best I've found is to abuse the for notation:
>
> for
On 2/28/2012 5:12 PM, Prasad, Ramit wrote:
Craig Yoshioka wrote:
I see that there was previously a PEP to allow the with statement to skip the
enclosing block... this was shot down, and I'm trying to think of the most
elegant alternative. [..]
I would have really liked:
with cachingcontext(
On Feb 24, 8:54 am, Steven D'Aprano wrote:
> for...else is a very useful construct, but the name is misleading. It
> took me a long time to stop thinking that the else clause executes when
> the for loop was empty.
Agreed. This is a major stumbling block for neophytes.
> In Python 4000, I think
On Feb 28, 12:13 pm, Jerry Hill wrote:
> On Tue, Feb 28, 2012 at 12:51 PM, Smiley 4321 wrote:
> > Can I have some thoughts about - building a GUI to display the results of
> > the pickle read?
Sure. But first can you show us some code that reads a pickled file
and prints the contents?
Hint: Why
It is a bit non-normal. but I think this is a good use case as I want to
create a very simple-to-use system for non-python experts to safely wrap their
CLI programs in a caching architecture... that's why I lament the inability to
not use the more streamlined 'with' syntax– abusing the for loo
On Wed, Feb 29, 2012 at 9:56 AM, Rick Johnson
wrote:
> On Feb 24, 8:54 am, Steven D'Aprano +comp.lang.pyt...@pearwood.info> wrote:
>
>> In Python 4000, I think for loops should be spelled:
>>
>> for name in iterable:
>> # for block
>> then:
>> # only if not exited with break
>> else:
>>
On 28/02/2012 9:07 PM, Andrea Crotti wrote:
How should I check if I can create files in a directory?
By trying to create them there :) Presumably you want to know that so
you can write something "real" - so just write that something real.
The problem gets quite hard when you consider things
On 28/02/2012 21:47, Arnaud Delobelle wrote:
On 28 February 2012 21:39, Mihai Badoiu wrote:
On Tue, Feb 28, 2012 at 4:35 PM, Chris Rebert wrote:
On Tue, Feb 28, 2012 at 10:33 AM, Mihai Badoiu wrote:
I'm trying to compute the total CPU load of an external process and it's
children. (so I c
On 02/28/2012 06:41 PM, Mark Lawrence wrote:
On 28/02/2012 21:47, Arnaud Delobelle wrote:
Please don't top-post! Also, psutil.Process.get_children() looks to
me like it "does" children.
You are incorrect. I've been told of by the BDFL for stating that
people should not top post on any Pyth
On Tue, 28 Feb 2012 23:41:16 +, Mark Lawrence wrote:
> I've been told of by the BDFL for stating that
> people should not top post on any Python mailing list/news group.
He's the BDFL of Python, not of mailing list etiquette.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-lis
Mark Lawrence writes:
> On 28/02/2012 21:47, Arnaud Delobelle wrote:
> > Please don't top-post! Also, psutil.Process.get_children() looks to
> > me like it "does" children.
>
> You are incorrect.
Incorrect? The only factual statement Arnaud made was about ‘psutil’.
> I've been told of by the B
On Wed, 29 Feb 2012 10:24:18 +1100, Chris Angelico wrote:
> Every syntactic structure should
> have the addition of a "foo:" suite, which will run when the programmer
> expects it to and no other time. This would solve a LOT of problems.
Indeed, when I design my killer language, the identifie
Craig Yoshioka wrote:
>It is a bit non-normal. but I think this is a good use case as I want to
>create a very simple-to-use system for non-python experts to safely wrap their
>CLI programs in a caching architecture... that's why I lament the inability to
>not use the more streamlined 'with' sy
On 29/02/2012 00:16, Steven D'Aprano wrote:
On Tue, 28 Feb 2012 23:41:16 +, Mark Lawrence wrote:
I've been told of by the BDFL for stating that
people should not top post on any Python mailing list/news group.
He's the BDFL of Python, not of mailing list etiquette.
Incorrect, I was to
Got a web site setup for solving euler problems in python, perl,
ruby and javascript.
Feel free to give me any feedback, thanks.
--
http://mail.python.org/mailman/listinfo/python-list
On Tue, Feb 28, 2012 at 10:59 PM, scripts examples <
example.scri...@gmail.com> wrote:
>
> Got a web site setup for solving euler problems in python, perl,
> ruby and javascript.
>
> Feel free to give me any feedback, thanks.
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
> > Hi,
> >
> > I have a simple configuration of modules as beneath, but an import error
> > is reported:
> >
> > /engine
> >(__init__ is empty here)
> >engine.py
> > /sim
> >__init__.py
> >
> >
> > The module engine.py imports a variable instantiated in sim.__init__ as
> > follows:
>
The book I'm reading about using Tkinter only does this when creating the
top-level window:
app = Application()
app.mainloop()
and of course the Application class has subclassed the tkinter.Frame class.
However, in the Python documentation, I see this:
root = Tk()
app = Application(master=root
Mark Lawrence writes:
> On 29/02/2012 00:16, Steven D'Aprano wrote:
> > On Tue, 28 Feb 2012 23:41:16 +, Mark Lawrence wrote:
> >> I've been told of by the BDFL for stating that people should not
> >> top post on any Python mailing list/news group.
> >
> > He's the BDFL of Python, not of maili
--
http://mail.python.org/mailman/listinfo/python-list
I was successful in testing pickle with multiple objects both READ & WRITE.
I did WRITE as -
---
#!/usr/bin/python
import pickle
class apple_Class(object):
def __init__(self, **kwds):
self.__dict__.update(kwds)
myInst = apple_Class()
myInst.FirstString = "Apple"
myInst.SecondString =
66 matches
Mail list logo