About 848,000 results
Open links in new tab
  1. What exactly is metaprogramming? - Stack Overflow

    Some comments in the article refer to metaprogramming as the ability to generate code (perhaps on the fly). Is metaprogramming the ability to generate code on the fly or is it the ability to inject methods and attributes into existing objects at runtime (like what some dynamic languages like Python, Ruby, and Groovy allow).

  2. Metaprogramming in Python - adding an object method

    I've got a background in Python (though entirely self-taught, so I might have some bad habits or misconceptions), and I'm trying to learn Ruby to broaden my scope. I was reading through some comparisons, and saw a lot of assertions that "Python can't do metaprogramming" (or, less inflammatorily, "Python can't do metaprogramming so simply as Ruby").

  3. python - How to support dynamic type hinting with …

    Jan 31, 2019 · Python is a dynamic language. That means an object can be anything, and can be transformed at run time. Certain features, like type-hinting, work by static analysis - and Pycharm toolchain did incorporate some type-hinting fetures that can also inspect Python's own dataclasses by static analysis.

  4. Python metaprogramming: generate a function signature with …

    May 17, 2018 · I am working within a Python web framework that uses Python 3 type annotations for validation and dependency injection. So I am looking for a way to generate functions with type annotations from a parameters given to the generating function:

  5. oop - What are metaclasses in Python? - Stack Overflow

    If you do so, Python will use the metaclass to create the class Foo. Careful, it's tricky. You write class Foo(object) first, but the class object Foo is not created in memory yet. Python will look for __metaclass__ in the class definition. If it finds it, it will use it to create the class object Foo.

  6. Python metaprogramming, dynamic types, and static type checking

    Apr 5, 2024 · FWIW even the most recent version of the book Fluent Python, in its metaprogramming section, seems not to implement any sort of type checking. goal. I am playing around with a dataframe framework - I want to be able to flexibly interact with (pandas) dataframes either in python or in sql, without having to cast them to dicts, etc.

  7. Python metaprogramming: automatically generate member …

    Sep 10, 2012 · Here's an real example from your newly posted code: import types def attach_on_sample_slider(obj, base): def on_sample_slider(self, value): self.samples = base**value self.sample_label.setText('%d' % self.samples) # This next line creates a method from the function # The first arg is the function and the second arg is the object # upon which you want it to be a method.

  8. python metaprogramming - Stack Overflow

    May 15, 2010 · I'm trying to archive a task which turns out to be a bit complicated since I'm not very good at Python metaprogramming. I want to have a module locations with function get_location(name), which returns a class defined in a folder locations/ in the file with the name passed to function. Name of a class is something like NameLocation.

  9. Python vs. Ruby for metaprogramming - Stack Overflow

    Sep 28, 2008 · Metaprogramming: Python supports metaclasses and runtime class/method generation etc; Syntax: Well thats somehow subjective. I like Pythons syntax for its simplicity, but some People complain that Python is whitespace-sensitive. Paradigms: Python supports procedural, object-oriented and basic functional programming.

  10. metaprogramming - Ruby’s “method_missing” in Python - Stack …

    Apr 5, 2017 · As others have mentioned, in Python, when you execute o.f(x), it's really a two-step operation: First, get the f attribute of o, then call it with parameter x. It's the first step that fails because there is no attribute f, and it's that step that invokes the …

Refresh