hello,
I've a perfect working procedure,
at least as far I've tested it it works perfect.
But I was just experimenting with inspect,
and saw that the default argument was not parsed correctly.
So I wonder if this is allowed:
def Get_Relative_Path ( target, base=os.curdir ) :
...
As inspect returns the following:
(['target', 'base'], None, None, ('.',))
thanks,
Stef Mientki 5 882
On Jul 28, 1:28*pm, Stef Mientki <stef.mien...@gmail.comwrote:
hello,
I've a perfect working procedure,
at least as far I've tested it it works perfect.
But I was just experimenting with inspect,
and saw that the default argument was not parsed correctly.
So I wonder if this is allowed:
def Get_Relative_Path ( target, base=os.curdir ) :
* ...
As inspect returns the following:
(['target', 'base'], None, None, ('.',))
thanks,
Stef Mientki
os.curdir is '.' on many platforms. What did you expect inspect to
show?
|>>import os
|>>os.curdir
'.'
On Jul 28, 3:28*pm, Stef Mientki <stef.mien...@gmail.comwrote:
hello,
I've a perfect working procedure,
at least as far I've tested it it works perfect.
But I was just experimenting with inspect,
and saw that the default argument was not parsed correctly.
So I wonder if this is allowed:
def Get_Relative_Path ( target, base=os.curdir ) :
Did you perhaps mean to say def Get_Relative_Path(target,
base=os.getcwd()):
* ...
As inspect returns the following:
(['target', 'base'], None, None, ('.',))
thanks,
Stef Mientki
Well, others have answered the question, but I thought I'd throw in
that it would be more pythonic to do something like:
def Get_Relative_Path(target, base = None):
if base is None:
base = os.curdir
...
"fred.haab" <fr*******@gmail.comwrites:
Well, others have answered the question, but I thought I'd throw in
that it would be more pythonic to do something like:
def Get_Relative_Path(target, base = None):
if base is None:
base = os.curdir
...
Even more Pythonic would be to name the function by the style guide
(PEP 8):
def get_relative_path(target, base=None):
if base is None:
base = os.curdir
# …
--
\ “If trees could scream, would we be so cavalier about cutting |
`\ them down? We might, if they screamed all the time, for no good |
_o__) reason.” —Jack Handey |
Ben Finney
fred.haab wrote:
Well, others have answered the question, but I thought I'd throw in
that it would be more pythonic to do something like:
def Get_Relative_Path(target, base = None):
if base is None:
base = os.curdir
...
Since os.curdir is a constant, this is nonesensical. One only needs the
dummy default when one wants an expression re-evaluated with each call. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Nick Coghlan |
last post by:
Time for another random syntax idea. . .
So, I was tinkering in the interactive interpreter, and came up with the
following one-size-fits-most default argument hack:
Py> x = 1
Py> def...
|
by: BRG |
last post by:
I know that default template arguments cannot be used in function
templates but are default function parameters legal?
That is, is this:
----------------------------------
#include <functional>...
|
by: Randell D. |
last post by:
Folks,
I'm sure this can be done legally, and not thru tricks of the trade - I
hope someone can help.
I'm writing a 'tool' (a function) which can be used generically in any
of my projects. ...
|
by: laredotornado |
last post by:
Hello, I am looking for a cross-browser way (Firefox 1+, IE 5.5+) to
have my Javascript function execute from the BODY's "onload" method,
but if there is already an onload method defined, I would...
|
by: K. Jansma |
last post by:
Hi,
given the following example class
class Test:
def f(self,a, L=):
L.append(a)
return L
and the following statements
|
by: Beta What |
last post by:
Hello,
I have a question about casting a function pointer. Say I want to make
a generic module (say some ADT implementation) that requires a function
pointer from the 'actual/other modules'...
|
by: Lighter |
last post by:
Why is template function not allowed to have defaut arguments?
We know that class template is allowed to have default arguments in C++
standard, why is template function not? I can't think out...
|
by: andrewfsears |
last post by:
I have a question: I was wondering if it is possible to simulate the
multiple constructors, like in Java (yes, I know that the languages are
completely different)?
Let's say that I have a class...
|
by: Guilherme Polo |
last post by:
On Mon, Jul 28, 2008 at 5:28 PM, Stef Mientki <stef.mientki@gmail.comwrote:
Are you referring to the last item in the tuple above ? It is merely
listing the default values, it is not associating...
|
by: antdb |
last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine
In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
|
by: Matthew3360 |
last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it so the python app could use a http request to get...
|
by: AndyPSV |
last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and...
|
by: Arjunsri |
last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
|
by: WisdomUfot |
last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
|
by: Oralloy |
last post by:
Hello Folks,
I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA.
My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
|
by: Carina712 |
last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
|
by: BLUEPANDA |
last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
|
by: Rahul1995seven |
last post by:
Introduction:
In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
| |