Hacker Newsnew | past | comments | ask | show | jobs | submit | qquark's commentslogin

It seems like it tends to converge into infinite loops at some point. Example by directly inputting a repeated "What?", originally obtained with a different piece of initial text, and observed with other starts as well :) :

Prompt:

"What?"

"What?"

"What?"

"What?"

"What?"

"What?"

"What?"

Response:

Same

I suppose it's kind of GPT's game of life :)


A 180kW kettle ?! Great Scott !


This may be what you're looking form, to add a method to a single instance, although the syntax is clearly not as smooth: https://stackoverflow.com/questions/1887845/add-method-to-an...

OTOH, if your problem is slightly different, I find the syntax to add methods to any class very practical and powerful, with of course the caveat that you can produce a maintainability nightmare if overused:

  irb(main):001:0> a = 1
  => 1
  irb(main):002:0> class Integer
  irb(main):003:1>   def hello
  irb(main):004:2>     puts "world"
  irb(main):005:2>   end
  irb(main):006:1> end
  => :hello
  irb(main):007:0> a.hello
  world
  => nil


This is maybe not directly visible in the parent comment, and particularly not on the website, that is compatible with old versions of python also, but to me there's a huge difference in usability also in the ability to use variable names in the current scope without additional verbose crap by default. This seems secondary to a lot of people, but to me that changes everything:

  >>> x = 1
  >>> f"{x}"
  '1'
This is much more readable than:

  >>> "{x}".format(x=x)
  '1'

  >>> "{}".format(x)
  '1'
It makes the code immensely more readable than having to count parameters, especially for long strings with a lot of data in them. Counting is for computers, not programmers; I shouldn't have to count anything for such a trivial task.

So, thanks to f"", no need for what I find to be an ugly additional call to .format(...), that is just visual clutter for most cases.

The only reasons I could see for a call with a dedicated dict is data exfiltration from a user provided format string executed on python code they do not control, or renaming/subsetting of keywords for cleanliness. Both are special cases, and that's the effect the current implementation has, thankfully.


I see your point, but the syntax inside of fstrings forms an entirely new sub-language (DSL). I can look at old python and know exactly how the .format() calls parse with positional and named keyword arguments, but looking at the fstrings I need to be familiar with all of the new magic.

I've heard similar complaints about the loop macro in Common Lisp, and this feels a bit like shell or Tcl strings which could mean anything (arguments to sed/awk or paths to widgets/urls). However, I guess people are familiar with regular expressions as a completely foreign nested language (DSL), so this isn't much different than that.


I disagree, especially when using named parameters. The new style is too implicit.


How is it implicit? Every insertion is expressed in exactly the place where it will print. It's way more explicit than having a placeholder and a value on completely different parts of the expression.


> It's way more explicit than having a placeholder and a value on completely different parts of the expression.

No its not.


  "My name is {}, I'm {}'{}'' tall and live in {}".format(name, location, feet, inches)
This error is much better hidden than in the equivalent:

  f"My name is {name}, I'm {location}'{feet}'' tall and live in {inches}."


I did mention named parameters, you are using positional parameters to make your point. You don't even list the variables in your example. That seems pretty implicit to me.

I think this is more explicit:

"My name is {name}, I'm {feet} tall and live in {location}.".format(name="Bob", location="USA", feet=7)


Your example is not representative because you're using literals.

Your actual example would be:

    "My name is {name}, I'm {feet} tall and live in {location}.".format(name=name, location=location, feet=feet)
And with f-strings:

    f"My name is {name}, I'm {feet} tall and live in {location}."
f-strings is clearly more readable, concise and actually faster to run.


The literals were just an example. And personally I find it more explicit, which is my original point.

If its faster to run, then fair enough.


Using your example, I think

"My name is {name}, I'm {feet} tall and live in {location}.".format(name="Bob", location="USA", feet=7)

is less explicit than

"My name is Bob, I'm 7 feet tall and live in USA."


and that last one is faster to run ;-)


Yes it is.


In case you didn't notice yet, it seems like the certificate of your website is expired (2019-04-10).


To be honest it just seems a bit like playing with words. Of course you can use "success" in sentences where it loses the meaning intended in the current context, but it seems clear to me that when someone writes "to be successful" there are implications that it means being successful on some measure that the author finds valuable or intends the reader to think valuable (in order to sell a book or something).

And of course people can argue all day about what is "being successful", since you could mostly put it as a matter of taste depending on what one finds satisfaction in, in life. It is indeed true that someone who doesn't have the same frame of reference for success as the author will have a harder time finding useful information in such a book/article, but that doesn't mean that because the measure of success can vary from person to person, it doesn't exist at all.

When such an article or book talks about that, there is a meaning behind those words that is conditioned by the cultural context in which it is used (as materialistic as it can be) and obviously this is pretty much never meant to be understood as "how to act as to be able to formulate statements that match 'I successfully did .*'", which is how this quote feels like to me...


You really should read the whole article. I definitely recognize what he talks about.

"It is perfectly obvious that in any decent occupation (such as bricklaying or writing books) there are only two ways (in any special sense) of succeeding. One is by doing very good work, the other is by cheating." (...)

"You may want to jump or to play cards; but you do not want to read wandering statements to the effect that jumping is jumping, or that games are won by winners. If these writers, for instance, said anything about success in jumping it would be something like this: "The jumper must have a clear aim before him. He must desire definitely to jump higher than the other men who are in for the same competition. He must let no feeble feelings of mercy (sneaked from the sickening Little Englanders and Pro-Boers) prevent him from trying to do his best. He must remember that a competition in jumping is distinctly competitive, and that, as Darwin has gloriously demonstrated, THE WEAKEST GO TO THE WALL." "

And the article then ends with:

"At least, let us hope that we shall all live to see these absurd books about Success covered with a proper derision and neglect. They do not teach people to be successful, but they do teach people to be snobbish; they do spread a sort of evil poetry of worldliness. The Puritans are always denouncing books that inflame lust; what shall we say of books that inflame the viler passions of avarice and pride? A hundred years ago we had the ideal of the Industrious Apprentice; boys were told that by thrift and work they would all become Lord Mayors. This was fallacious, but it was manly, and had a minimum of moral truth. In our society, temperance will not help a poor man to enrich himself, but it may help him to respect himself. Good work will not make him a rich man, but good work may make him a good workman. The Industrious Apprentice rose by virtues few and narrow indeed, but still virtues. But what shall we say of the gospel preached to the new Industrious Apprentice; the Apprentice who rises not by his virtues, but avowedly by his vices?"


As I was reading point 1 of Sam's article, Compound yourself, I was thinking, ah ok, teachers are in the wrong field evidently, for Success. They can never be exponentially increasing their force and effect in the way suggested.

Although there are people like Gilbert Strang, making his excellent courses (e.g. Linear Algebra) available online, which over a million people around the world have watched and benefited from, and helping to create a world with an amazing variety of free online course videos available in all subjects. That is success for a teacher, I suppose. And we're asked to believe (in this culture) that making a lot of money is or could be in any worthy sense a greater success..


Teachers compound society, which is extremely valuable but doesn't make them rich.


You should read the article I linked to! Sadly it was a bit too long to paste the whole thing.

When I was younger, my father gave me a thick and nauseating compendium labelled The University of Success, filled with extracts from vacuous books of the kind Chesterton talks about. I guess he thought I wasn't 'successful', and it would teach me how! By then I'd already read and got a lot from some of the useful books in the field - Awaken the Giant Within, Life 101, How to Win Friends and Influence People, The New Guide to Rational Living, Effortless Mastery, The Art of Possibility etc. For the kind of success I value most, I've been inspired for decades by, and owe the most to, writers such as Robert Fulghum, SARK, and most of all, Emerson.


When not too constrained by size and particularly for prototyping, I tend to use short descriptive names that are not too hard to decode. For example you could use Cby* for bypass capacitors, or maybe if you have a series of LEDs, then you could have Dr, Dg, Db* depending on their color, and similarly Rr, Rg, Rb* for their respective resistors, or Rpi* for I2C pull-up resistors, etc.

Sure you could have a look a the traces to find those out, but it's not always straightforward.

This makes a big difference when debugging boards IMO. For example now if you see that your blue LED is too bright again (as is usually the case ;)), you can just look for Rb* and fix it without the schematic.


I've been using enforce for this purpose (https://github.com/RussBaz/enforce). It provides decorators that enable type checking where wanted. This gives the advantage of migrating existing code to type checking at your own pace at least.

On a general note I've come across a few cases, when pushing python's type annotations to their limits, that force you to put the type names in string quotes, and that makes the whole thing feel like a hack. It's better than nothing for my use cases, but if I remember correctly both mypy and enforce have problems in common that are probably coming from the way python itself is built, such as self reference in a class definition.


> I've come across a few cases, when pushing python's type annotations to their limits, that force you to put the type names in string quotes

With pep-0563, python3.7, and `from __future__ import annotations` this should no longer be necessary. Those are some pretty detailed caveats, but I have been using it in places where I can and it is so nice.


> but it is very unclear how to do it with a distributed repository

Versioning through branching and tagging, while having some drawbacks - at least the fact that you have to DO an operation and that this is not automatic - seem to solve this problem, and are not, in my eyes, a form of monorepo. You globally get more flexibility at the cost of a bit more repo management work.

If the problem is retrieving the right version automatically, externals or submodules should be able to solve this problem. If A and B have no clear dependency direction, a top level repo might help.


> a top level repo might help.

This is the way I generally do it: A repository that represents my system/environment that has submodules for A1, A2, B1, and B2, and scripts for updating the environment.


Also being in France, I find that the most reliable and practical way to get something shipped is to use a "point relai" (when delivery at work is out of the picture because of company policies). Delivery services generally know better how to find them and deal with them, since other people use them too.

When your package is damaged, some will even offer to add a note to your delivery, without you asking, in case there's a problem later.

I order very regularly from Amazon, and I think I have never had a single problem receiving packages this way, and it's pretty easy to find one on your way from work or somewhere that suits you. Some of them are even open on Sunday, depending on what their main business is, very convenient ...


Yes I'm trying to use point relais right now whenever possible. However oftentimes Amazon says to me that the items I want to buy can't be delivered to point relais (probably there are restrictions on size and type of products).


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: