Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 820513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T02:29:13+00:00 2026-05-15T02:29:13+00:00

It seems pretty common to me to have an argument, in a dynamically typed

  • 0

It seems pretty common to me to have an argument, in a dynamically typed language that is either an Object or a key to lookup that object. For instance when I’m working with a database I might have a method getMyRelatedStuff(person)

All I really need to lookup the related stuff is the id of the person so my method could look like this in python:

def getMyRelatedStuff(person_or_id):
    id = person_or_id.id if isinstance(person,User) else person_or_id
    #do some lookup

Or going the other direction:

def someFileStuff(file_or_name):
    file = file_or_name if hasattr(file,'write') else open(file_or_name)

EDIT: I am looking for a built in syntax for this, the closest I can think of is implicit and explicit keywords in C# that allow you to define a cast between types.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T02:29:14+00:00Added an answer on May 15, 2026 at 2:29 am

    I study programming languages for a living. I’ve never seen a language with a built-in syntax for that operation. I’m not even sure what you want such a syntax to look like, especially since you can define a function for any of these patterns.

    People who like extensible syntax tend to define Lisp macros 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have what seems to be a pretty common CSS inheritance situation, but I
I have some pretty common Haskell boilerplate that shows up in a lot of
The question seems pretty well formulated I have a virtual machine which implements only
The javascript one seems pretty simple, just localStorage.clear(). Is there anything similar to that
Ant seems to be pretty bad as running interactive program. So for instance, a
It seems that JINI is pretty much an abandoned project. The latest release from
It seems that these two operators are pretty much the same - is there
This seems like it would be pretty common task, but I'm not having any
I have a common scenario that I am looking for some guidance from people
this should be pretty common yet I find it fascinating that I couldn't find

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.