473,324 Members | 2,567 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

the lvalue curse? let's play with this crazy idea ;)

I started playing with Python and love it since the very beginning,
programming using Python is so ...human-like? but one thing returns to
me almost everytime when I see/write the code
Let's take a look at two ways of thinking...
the standard one which is well-known and loved by almost everyone :)
and that crazy concept below which suprised evan me :wacko:

<code>
import time

ftime = time.time()
localtime = time.localtime(ftime)
localtime = list(localtime[:3])
localtime = [str(i) for i in localtime]
print '-'.join(localtime)
</code>

It's harder to read than the below concept, isn't?
Maybe I didn't used to this way of thinking yet. I hope it'll change
soon or i'll quit ;)
<almost code>
time.time() -ftime -time.localtime() -p -p[:3] -g -list(g)
-'-'.join()
</almost code>

My example conclusion and not-ansewered-yet question...
-it's nice to read and choosing the good names to variables aren't so
important
-what is the purpose of the variables here? :)

I realize that there is no chance to implement it, but I really want
to share it :]

Peace,
T.

PS
forgive my my english
[shall I set it as a signature? ;) ]
Jun 27 '08 #1
4 988
On Fri, 09 May 2008 02:13:34 -0700, XLiIV wrote:
Let's take a look at two ways of thinking...
the standard one which is well-known and loved by almost everyone :)
and that crazy concept below which suprised evan me :wacko:

<code>
import time

ftime = time.time()
localtime = time.localtime(ftime)
localtime = list(localtime[:3])
localtime = [str(i) for i in localtime]
print '-'.join(localtime)
</code>

It's harder to read than the below concept, isn't?
Maybe I didn't used to this way of thinking yet. I hope it'll change
soon or i'll quit ;)
Maybe it's also harder to read than this::

print '-'.join(map(str, time.localtime()[:3]))

Of course, if you don't mind the extra padding zeroes in day and month::

print time.strftime('%Y-%m-%d')
<almost code>
time.time() -ftime -time.localtime() -p -p[:3] -g -list(g)
-'-'.join()
</almost code>
You are a little bit inconsistent with the arguments. `g` is explicitly
mentioned in ``list(g)``. But why the intermediate names at all?
My example conclusion and not-ansewered-yet question...
-it's nice to read and choosing the good names to variables aren't so
important
-what is the purpose of the variables here? :)
Exactly. But look at my snippet above: No intermediate names either.
I realize that there is no chance to implement it, but I really want
to share it :]
Maybe you should look into languages like SmallTalk or Io where everything
is done with method calls. Your example in Io::

Date now do("#{year}-#{month}-#{day}" interpolate linePrint)

Ciao,
Marc 'BlackJack' Rintsch
Jun 27 '08 #2
XLiIV a écrit :
I started playing with Python and love it since the very beginning,
programming using Python is so ...human-like? but one thing returns to
me almost everytime when I see/write the code
Let's take a look at two ways of thinking...
the standard one which is well-known and loved by almost everyone :)
and that crazy concept below which suprised evan me :wacko:

<code>
import time

ftime = time.time()
localtime = time.localtime(ftime)
localtime = list(localtime[:3])
You don't need the call to list here.
localtime = [str(i) for i in localtime]
print '-'.join(localtime)
</code>

It's harder to read than the below concept, isn't?
Maybe I didn't used to this way of thinking yet. I hope it'll change
soon or i'll quit ;)
<almost code>
time.time() -ftime -time.localtime() -p -p[:3] -g -list(g)
-'-'.join()
</almost code>
print "-".join(map(str, localtime(time.time())[:3]))

or

print "-".join(str[item] for item in localtime(time.time())[:3])

My example conclusion and not-ansewered-yet question...
-it's nice to read
Very subjective point here. I'm afraid I don't share your POV.
and choosing the good names to variables aren't so
important
-what is the purpose of the variables here? :)
help debugging ? make code easier to grasp ?
I realize that there is no chance to implement it,
In Python ? Not a chance, indeed.

Jun 27 '08 #3
On May 9, 11:52*am, Marc 'BlackJack' Rintsch <bj_...@gmx.netwrote:
Maybe it's also harder to read than this::

* print '-'.join(map(str, time.localtime()[:3]))
I like this concept, it's so, .. ziped :)
Of course, if you don't mind the extra padding zeroes in day and month::

* print time.strftime('%Y-%m-%d')
I'll be humble, it covers my need the most :)
If you have a lack of knowladge you work harder...
One instruction (besides 'print')... . Do you believe it? :)

You are a little bit inconsistent with the arguments. *`g` is explicitly
mentioned in ``list(g)``. *But why the intermediate names at all?
That's right, because it was just a scratch of an idea..
The point of the idea was this...
I read from left to right, and because of that it's easier to me
follow this way of writing (you only follow by one direction and the
value is handing over, from left to rigght ...):

value -do_something -result -action_on_the_result -...

than this multiline lvalues assignes

variable = value # I take a look at the left then the right
result = do_something(variable) # Here I check also left and right
side, and perhaps I (a short memory) may check the line over
action_on_the_result(result)
...

However, I've just found out, that even the more difficult method to
me isn't so scary if I read it like this
...
6 7
4 5
2 3
1
However the 2nd:
because there is:
print '-'.join(map(str, time.localtime()[:3]))

so i'm not serious convincing anyone :)

Maybe you should look into languages like SmallTalk or Io where everything
is done with method calls. *Your example in Io::
I took a brief look at them, and Python is still Nr OnE :)
Jun 27 '08 #4

"XLiIV" <Ty*****************@gmail.comwrote in message
news:68**********************************@p25g2000 hsf.googlegroups.com...

Pipelining works best when all functions have just one input.
But that is a small subset of actual programs.

Jun 27 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
by: Hongzheng Wang | last post by:
In K&R, they said: An object is a named region of storage; an lvalue is an expression refer to an object. How about these concept in C++? `The C++ Programming Language' has a similar...
28
by: stu_gots | last post by:
I have been losing sleep over this puzzle, and I'm convinced my train of thought is heading in the wrong direction. It is difficult to explain my circumstances, so I will present an identical...
16
by: Martijn | last post by:
Hi, I recently updated my version of gcc (to gcc version 3.4.2 (mingw-special) ), and I get a warning I am not too sure about how to best solve: warning: use of cast expressions as lvalues is...
3
by: Kavya | last post by:
Can someone give and explain in simple terms a definition of lvalue? Also what are these modifiable and non-modifiable lvalues? I always thought that, if we can assign to anything then that...
10
by: the_init | last post by:
Hi friends, I read about Lvalue in previous posting and Googled it but I'm not understood it completely. There is a small doubt. int a; a=20; // here a is Lvalue But
232
by: robert maas, see http://tinyurl.com/uh3t | last post by:
I'm working on examples of programming in several languages, all (except PHP) running under CGI so that I can show both the source files and the actually running of the examples online. The first...
14
by: nobrow | last post by:
Yes I know what lvalue means, but what I want to ask you guys about is what are all valid lvalues ... a *a a *(a + 1) .... What else?
4
by: Shraddha | last post by:
Sometimes we get an error of lvalue requred?What exactly is the lvalue? And when this error occures?
54
by: Rahul | last post by:
Hi Everyone, I have the following piece of code, and i expected an error, however i don't get an error, int main() { int aa=0,b=0; 1>0?aa:b = 10; printf("value %d %d\n",aa,b);
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.