🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: pl.comp.lang.python
5 messages
5 total messages Started by Piotr Hosowicz Thu, 26 Mar 2009 18:35
Czy jest takie idiomatyczne sformułowanie? "" jeśli wartość Null
#25909
Author: Piotr Hosowicz
Date: Thu, 26 Mar 2009 18:35
15 lines
1117 bytes
Witam,

x = Null
y = "Cos"

"%s %s" % (x,y)

... daje "None Cos"

Na razie radzę sobie ifami-elsami, ale czy jest jakieś idiomatyczne 
sformułowanie w Pythonie które to rozwiązuje?

Z góry dziękuję,

Piotr Hosowicz
Re: Czy jest takie idiomatyczne sformułowanie? "" jeśli wartość Null
#25911
Author: Radomir Dopieralski
Date: Thu, 26 Mar 2009 18:46
21 lines
1662 bytes
At Thu, 26 Mar 2009 19:35:21 +0100, Piotr Hosowicz wrote:

> Witam,
>
> x = Null
> y = "Cos"
>
> "%s %s" % (x,y)
>
> ... daje "None Cos"
>
> Na razie radzę sobie ifami-elsami, ale czy jest jakieś idiomatyczne 
> sformułowanie w Pythonie które to rozwiązuje?

Ale co rozwiazuje?
Opisales zachowanie, ktore jest jak najbardziej normalne w pythonie, ale
nie problem. Co chcialbys uzyskac?


-- 
Radomir Dopieralski, http://sheep.art.pl
Re: Czy jest takie idiomatyczne sformułowanie? "" jeśli wartość Null
#25912
Author: Wojciech Muła
Date: Thu, 26 Mar 2009 18:51
16 lines
1352 bytes
On Thu, 26 Mar 2009 19:35:21 +0100 Piotr Hosowicz
<adresat.nieprawidlowski@op.pl> wrote:

> Witam,
> 
> x = Null
> y = "Cos"
> 
> "%s %s" % (x,y)
> 
> ... daje "None Cos"
> 
> Na razie radzę sobie ifami-elsami, ale czy jest jakieś idiomatyczne 
> sformułowanie w Pythonie które to rozwiązuje?

"%s %s" % (x or 'domyślny X', y or 'domyślny Y')
Re: Czy jest takie idiomatyczne sformułowanie? "" jeśli wartość Null
#25910
Author: forgems
Date: Thu, 26 Mar 2009 18:53
20 lines
1628 bytes
On Mar 26, 7:35 pm, Piotr Hosowicz <adresat.nieprawidlow...@op.pl>
wrote:
> Witam,
>
> x = Null
> y = "Cos"
>
> "%s %s" % (x,y)
>
> ... daje "None Cos"
>
> Na razie radzę sobie ifami-elsami, ale czy jest jakieś idiomatyczne
> sformułowanie w Pythonie które to rozwiązuje?
>
> Z góry dziękuję,
>
> Piotr Hosowicz
Moze to:
"%s %s" % (x or '',y or '')
?
Re: Czy jest takie idiomatyczne sformułowanie? "" jeśli wartość Null
#25913
Author: Piotr Hosowicz
Date: Thu, 26 Mar 2009 19:58
23 lines
1489 bytes
Wojciech Muła wrote:
> On Thu, 26 Mar 2009 19:35:21 +0100 Piotr Hosowicz
> <adresat.nieprawidlowski@op.pl> wrote:
> 
>> Witam,
>>
>> x = Null
>> y = "Cos"
>>
>> "%s %s" % (x,y)
>>
>> ... daje "None Cos"
>>
>> Na razie radzę sobie ifami-elsami, ale czy jest jakieś idiomatyczne 
>> sformułowanie w Pythonie które to rozwiązuje?
> 
> "%s %s" % (x or 'domyślny X', y or 'domyślny Y')

Dzięki Wam obydwu, Panowie.

Pozdrawiam,

Piotr Hosowicz
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads