473,799 Members | 2,734 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(localtim e)
</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 1004
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(localtim e)
</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(localtim e)
</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.net wrote:
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_r esult -...

than this multiline lvalues assignes

variable = value # I take a look at the left then the right
result = do_something(va riable) # Here I check also left and right
side, and perhaps I (a short memory) may check the line over
action_on_the_r esult(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.com wrote in message
news:68******** *************** ***********@p25 g2000hsf.google groups.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
36662
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 explanation, however, it may be too brief. Can anyone give me a more detailed explanation? Or give some referrences
28
3308
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 make-believe challenge in order to avoid confusing the issue further. Suppose I was hosting a dinner and I wanted to invite exactly 12 guests from my neighborhood. I'm really picky about that... I have 12 chairs besides my own, and I want them all...
16
12086
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 deprecated The code that invokes this warning has to do with PIDLs (pointer to item id list, which are a Windows thing and not too important really). The problem
3
5770
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 anything is lvalue and if cannot assign to anything then that anything is not lvalue.
10
2938
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
13360
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 set of examples, after decoding the HTML FORM contents, merely verifies the text within a field to make sure it is a valid representation of an integer, without any junk thrown in, i.e. it must satisfy the regular expression: ^ *?+ *$ If the...
14
4381
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
2266
by: Shraddha | last post by:
Sometimes we get an error of lvalue requred?What exactly is the lvalue? And when this error occures?
54
3221
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
9544
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10490
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10259
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10238
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7570
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6809
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5467
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5589
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3761
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.