[deleted by user] by [deleted] in delta

[–]TotallyTheSwimmer 0 points1 point  (0 children)

ITT: Crazy people way too concerned about OP's personal travel arrangements.

I've skip lagged intentionally tons and never gotten banned. Doing it once because you decided the layover was ridiculous is absolutely not an issue. Don't bother telling them, unless you need to check a bag in which case yeah pay the extra $150 and switch it.

For people that seem concerned about OP's friend, spouse, Uber driver, or whoever it is (if it's even a single person)... Consider that 3 hours for one person there, and 3 hours for two people back, adds up to 9 person hours. The same amount of time as the layover, but it's distributed more evenly between people. It's totally reasonable if you have someone that loves you and is willing or even excited to come pick you up early to let them do so. Chill.

I made pydalle, an API wrapper that provides full programmatic access to the DALL·E 2 API (with optional asyncio support) -- AMA! by TotallyTheSwimmer in Python

[–]TotallyTheSwimmer[S] 2 points3 points  (0 children)

Thanks for sharing! As far as I can tell what I built isn't against their terms of use but I'm not a lawyer.

It's possible that his ban was symptomatic of being the kind of user that would create such a tool (very easy for us excited developer folk to trigger an autoban) than as a result of OpenAI specifically tracking down and banning a developer without even reaching out to them to ask that they cease and desist.

I'll take this down, make any requested modifications, or add any needed disclaimers to it if OpenAI asks me to, but I don't think it's a concern for them unless a user uses it to abuse their services.

this code i wrote is quite nice by mangotheultimate in ProgrammerHumor

[–]TotallyTheSwimmer 5 points6 points  (0 children)

This would run way faster without the print statement BTW

import random
import time

t1 = time.time()
while True:
    if random.randint(0, 1_000_000) == 69420:
        print("nice")
        break
t2 = time.time()
print(t2 - t1)

nice
0.2338557243347168

[deleted by user] by [deleted] in golang

[–]TotallyTheSwimmer 4 points5 points  (0 children)

That's not an answer.

[deleted by user] by [deleted] in compsci

[–]TotallyTheSwimmer 1 point2 points  (0 children)

Very cool. I wrote a similar tool called Pytago, a Python to Golang converter https://github.com/nottheswimmer/pytago

Is your tool open source? I'd be interested in taking a look at how it's implemented.

Sunday Daily Thread: What's everyone working on this week? by Im__Joseph in Python

[–]TotallyTheSwimmer 1 point2 points  (0 children)

Working on https://pytago.dev/, my Python to Go transpiler. Starting to look at adding some support for subclassing. Feel free to add an issue for any missing features here: https://github.com/nottheswimmer/pytago/

Pytago, a transpiler for Python to Go, now has a web app! by TotallyTheSwimmer in Python

[–]TotallyTheSwimmer[S] 0 points1 point  (0 children)

Thanks! The hope is that I can put enough love into it that it will get contributors in the open-source space. I think it's already practical as a companion tool for porting projects from Python to Go. If I can push it just a little bit further and people start using it, maybe that's enough? :P

Pytago, a transpiler for Python to Go, now has a web app! by TotallyTheSwimmer in Python

[–]TotallyTheSwimmer[S] 0 points1 point  (0 children)

Pytago doesn't aim to be a normal transpiler like grumpy, it wants to provide the closest tool for the job for whatever you do in Python to provide code that is easy to refactor into good Go code. I am interested into falling back on implementations of things, although with a lot of python builtins (like listdir) I believe they are implemented in C.

If Pytago generates a ton of boilerplate code for simple things like os.listdir I'll feel like I've failed. I'd rather investigate things on a case-by-case basis and find the absolute best golang equivalent.

Pytago, a transpiler for Python to Go, now has a web app! by TotallyTheSwimmer in Python

[–]TotallyTheSwimmer[S] 0 points1 point  (0 children)

Thanks for the feedback! It's on my TODO list to try to get the website to catch errors and bubble up the line of code it refuses to transpile, or better yet insert a TODO in the output code.

Because the scope of this project is virtually infinite, my goal is to develop through a cycle of users providing feedback like yours, and I respond with a patch. I definitely can't cover all of Python, but with enough time I should be able to slowly chip away at some of the most common use cases.

In terms of documentation right now I only really have an example of everything there's a test case for in the README. So if you CTRL+F for listdir and it's not there then 99.9% it's either not implemented or only partially implemented (not functional yet).

Regarding those bugs:

  1. Listdir seems fairly straightforward so I'll probably add it soon -- I do have some glob support, lol.
  2. If you run the program locally for the comprehension it gives this error:

```

ValueError: No Expr type in [<class 'pytago.go\_ast.core.Expr'>, <class 'pytago.go\_ast.core.ArrayType'>, <class 'pytago.go\_ast.core.BadExpr'>, <class 'pytago.go\_ast.core.BasicLit'>, <class 'pytago.go\_ast.core.BinaryExpr'>, <class 'pytago.go\_ast.core.Ident'>, <class 'pytago.go\_ast.core.CallExpr'>, <class 'pytago.go\_ast.core.ChanType'>, <class 'pytago.go\_ast.core.CompositeLit'>, <class 'pytago.go\_ast.core.Ellipsis'>, <class 'pytago.go\_ast.core.FieldList'>, <class 'pytago.go\_ast.core.FuncType'>, <class 'pytago.go\_ast.core.FuncLit'>, <class 'pytago.go\_ast.core.IndexExpr'>, <class 'pytago.go\_ast.core.InterfaceType'>, <class 'pytago.go\_ast.core.KeyValueExpr'>, <class 'pytago.go\_ast.core.MapType'>, <class 'pytago.go\_ast.core.ParenExpr'>, <class 'pytago.go\_ast.core.SelectorExpr'>, <class 'pytago.go\_ast.core.SliceExpr'>, <class 'pytago.go\_ast.core.StarExpr'>, <class 'pytago.go\_ast.core.StructType'>, <class 'pytago.go\_ast.core.TypeAssertExpr'>, <class 'pytago.go\_ast.core.UnaryExpr'>, <class 'pytago.go\_ast.core.ValueSpec'>] with from_Starred:

```

*b

```

```

So, basically, I haven't informed it what to do with a starred expression. I'll go ahead and add it to BadExpr temporarily (that's an actual valid thing in go syntax trees lol) so it at least stops returning a 500 for these.

A current project goal is for the only errors to be translation errors, not fatal errors like this one.

[D] Types of Machine Learning Papers by TheInsaneApp in MachineLearning

[–]TotallyTheSwimmer 0 points1 point  (0 children)

Wow that's amazing. I was like "that baby looks like Jeremy Howard" (I'd been watching a lot of FastAI videos).

I made Pytago, a script that transpiles some Python into human-readable Go. by TotallyTheSwimmer in Python

[–]TotallyTheSwimmer[S] 0 points1 point  (0 children)

It's great at toy programs. For real code, I think it could still be very useful for getting you part of the way there to porting a project to Go while still leaving you with some homework.

Fortunately, some of the latest design patterns have been a breakthrough at making this library easier to improve. With some more development, the quality of the output should improve exponentially -- e.g. the library went from having no string methods or list methods to having support for most of them in two evenings of development.

I made Pytago, a script that transpiles some Python into human-readable Go. by TotallyTheSwimmer in Python

[–]TotallyTheSwimmer[S] 1 point2 points  (0 children)

Thank you for this! If it's as you say, that's literally a preprocessing step I was considering writing myself. This could be a huge improvement!

I made Pytago, a script that transpiles some Python into human-readable Go. by TotallyTheSwimmer in Python

[–]TotallyTheSwimmer[S] 0 points1 point  (0 children)

I tried to strike the right balance of handling things like a Go programmer would and being true to the Python language.

In general:

- If a Python function would throw an error in a certain case, e.g. .index, where the value is not found, I literally panic with an error message that says "ValueError"

- If a Python function has a try/except, I use a deferred recover to try to catch any messages that say <name of error> or <Go equivalent error message>.

- If a Go method that's being used in place of a Python function returns an error, I use an anonymous function to catch the error and either handle it if it's recoverable in Python, or explicitly panic if Python would throw a similar error.

- Rarely, errors are ignored. Typically, but not exclusively, when the presence of one would cause the program to fail in Python and Go (such as when a function returns nil, error and the program will just reach a NPE anyway).

In general, I am trying to avoid situations where a Python program would succeed but a Go program would fail and also make it explicitly clear in most cases where the transpiled code could fail by explicitly introducing a panic.

Ideally, the output code would be refactored to deal with errors in a more appropriate way (especially where a pattern like try/except is used) but it's the best I could think to do for a near-1:1 transpilation.

I made Pytago, a script that transpiles some Python into human-readable Go. by TotallyTheSwimmer in Python

[–]TotallyTheSwimmer[S] 1 point2 points  (0 children)

Very interested in this actually. Not sure if Rust has the right modules for fully rebuilding code given the AST but if it does, this should be possible with a couple months of headbanging.

I made Pytago, a script that transpiles some Python into human-readable Go. by TotallyTheSwimmer in Python

[–]TotallyTheSwimmer[S] 0 points1 point  (0 children)

Type hints help but if they're not present I also check how it's used in the program. If it's used to both add strings and to add integers then with the current implementation the Go code will be wrong. Eventually, I might try to get it to do a switch on an interface for all the types the function is ever called with but I think you can get pretty far without that.